onselect 問題
<b>Date: <input type="text" id="datepicker" name="datepicker" readonly="true"></b>
<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>
<%@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);
%>
我想select datepicker,用onselect 拿/Doctor/booking/gettime.jsp?datepicker 的value,pass去gettime.jsp處理...
但是這種方法沒效
补充:Java , Web 开发