- Java code
<b>Date: <input type="text" id="datepicker" name="datepicker" readonly="true"></b>
- Java code
<script type="text/javascript"> $(function() { $("#datepicker").datepicker({dateFormat: 'yy-mm-dd', maxDate: '+1m', minDate: 'Now', beforeShowDay: noSundays, onSelect: function(dateText, inst) { $.ajax({ url: "/Doctor/booking/gettime.jsp", type: 'GET', data: { datepicker: $(this).val() }, success: function(result) { $("#datepicker").val(result); } }); } }); }); var noSundays = function(a) { var day = a.getDay(); return [day > 0 && day < 7, '']; };</script>
- Java code
<%@page language="java" import ="java.sql.*" %> <% Connection conn = null; String url = "jdbc:oracle:thin:@kk132.no-ip.org:1521:"; String dbName = "XE"; String driver = "oracle.jdbc.OracleDriver"; String userName = "kk"; String password = "thegame1"; String data1=""; String country=request.getParameter("datepicker"); out.print("country"); String[] stArray=new String[4]; stArray[0]="9:00"; stArray[1]="9:15"; stArray[2]="9:30"; stArray[3]="9:45"; String buffer="<select name='time'><option value=''>Select</option>"; Class.forName(driver).newInstance(); Connection con = DriverManager.getConnection(url+dbName,userName,password); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("Select * from booking"); if(country.equals(rs.getString(4))) for(int i=0;i<stArray.length;i++){ if(!stArray[i].equals(rs.getString(5))) buffer=buffer+"<option value='"+stArray[i]+"'>"+stArray[i]+"</option>"; } buffer=buffer+"</select><br/><br/>"; response.getWriter().println(buffer); %>
為什麼我不能
out.print("country"); //country value
我只想透過onselect 來get 這個datepicker value,去交給另一jsp去處理data
------解决方案--------------------
应当是out.print(country); 吧
怎么还用“”括起来了