php+jquery做onchange提交动作的问题,请人帮忙看看
我有个列表出来的结果,每列都有个onchange的动作,可是只有第一行的onchange可以操作,其他都没有反应,不知道怎么回事。
PHP jQuery onchange
<?
include("../config.inc.php");
//医生排班列表开始
$strDoctorTime = "";
if( isset($_REQUEST['Action']) && !empty($_REQUEST['Action']) && ($_REQUEST['Action'] == "setdoctortime") ){
$sqlDoctorTime = "select sid,doctorid,CONVERT(varchar(100), starttime, 20) as starttime,CONVERT(varchar(100), endtime, 120) as endtime,duration,createtime,type,operid,status,visits_counts,original_counts,istrue from gst_scheduling where doctorid = '".$_REQUEST['doctorid']."' ";
//if ( (isset($_REQUEST['starttime']) && !empty($_REQUEST['starttime'])) && (isset($_REQUEST['endtime']) && !empty($_REQUEST['endtime'])) ) {
//$sqlDoctorTime .= " ";
//}
$sqlDoctorTime .= " order by sid desc";
$resDoctorTime = $SqlDB->Query($sqlDoctorTime);
$arrDoctorTime = $SqlDB->getRows($resDoctorTime);
for($i=0; $i<count($arrDoctorTime); $i++) {
$strSelectStatus = ""; //初始号源下拉值
$strSelectStatus = "<select name="originalcounts" id="originalcounts">";
$strSelectStatus .= "<option value="1|".$arrDoctorTime[$i]['sid']."" ";
if(trim($arrDoctorTime[$i]['original_counts']) == "1") $strSelectStatus .= ' selected';
$strSelectStatus .= ">1</option>";
$strSelectStatus .= "<option value="2|".$arrDoctorTime[$i]['sid']."" ";
if(trim($arrDoctorTime[$i]['original_counts']) == "2") $strSelectStatus .= ' selected';
$strSelectStatus .= ">2</option>";
$strSelectStatus .= "<option value="3|".$arrDoctorTime[$i]['sid']."" ";
if(trim($arrDoctorTime[$i]['original_counts']) == "3") $strSelectStatus .= ' selected';
$strSelectStatus .= ">3</option>";
$strSelectStatus .= "<option value="4|".$arrDoctorTime[$i]['sid']."" ";
if(trim($arrDoctorTime[$i]['original_counts']) == "4") $strSelectStatus .= ' selected';
$strSelectStatus .= ">4</option>";
$strSelectStatus .= "<option value="5|".$arrDoctorTime[$i]['sid']."" ";
if(trim($arrDoctorTime[$i]['original_counts']) == "5") $strSelectStatus .= ' selected';
$strSelectStatus .= ">5</option>";
$strSelectStatus .= "<option value="6|".$arrDoctorTime[$i]['sid']."" ";
if(trim($arrDoctorTime[$i]['original_counts']) == "6") $strSelectStatus .= ' selected';
$strSelectStatus .= ">6</option>";
$strSelectStatus .= "<option value="7|".$arrDoctorTime[$i]['sid']."" ";
if(trim($arrDoctorTime[$i]['original_counts']) == "7") $strSelectStatus .= ' selected';
$strSelectStatus .= ">7</option>";
$strSelectStatus .= "<option value="8|".$arrDoctorTime[$i]['sid']."" ";
if(trim($arrDoctorTime[$i]['original_counts']) == "8") $strSelectStatus .= ' selected';
$strSelectStatus .= ">8</option>";
$strSelectStatus .= "<option value="9|".$arrDoctorTime[$i]['sid']."" ";
if(trim($arrDoctorTime[$i]['original_counts']) == "9") $strSelectStatus .= ' selected';
$strSelectStatus .= ">9</option>";
$strSelectStatus .= "<option value="10|".$arrDoctorTime[$i]['original_counts']."" ";
if(trim($arrDoctorTime[$i]['original_counts']) == "10") $strSelectStatus .= ' selected';
$strSelectStatus .= ">10</option>";
$strSelectStatus .= "</select>";
}
}
//医生排班列表结束
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title></title>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="/css/admin.css" type="text/css" rel="stylesheet">
</HEAD>
<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="http://www.360gst.com/datepicker/WdatePicker.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#originalcounts').change(function(){
alert("33333");
if(!confirm('确定提交')) return;
var p1 = $(this).val();
alert(p1);
$("#originalcounts").attr("disabled","disabled");
postdata(p1);
$("#originalcounts").attr("disabled","");
});
});
function postdata(p1){
alert(p1);
alert("222");
$("#loading").fadeOut("slow")
$.ajax({
type: "POST",
url: "ajax_changedoctorcount.php",
data: "sid="+p1,
beforeSend:function(XMLHttpRequest){
//$("#showResult").text("数据更新中,请稍后.......");
$("#showResult").html('<img src="images/ajax-loader-eeeeee.gif">Loading...');
//show loading images
//Pause(this,100000);
},
success: function(msg){
//ajaxCheckRes(msg);
//alert(msg);
//alert("11111111");
//$("#showResult").html(msg);
//$("#showResult").css("color","red");
//$(Element).removeClass("loading");
alert("message:"+msg);
$("#showResult").hide();
if( msg == "ok1" ) {
alert("数据提交成功"); //如果有必要,可以把msg变量的值显示到某个DIV元素中
}
if( msg == "error" ) {
alert("订单编号丢失"); //如果有必要,可以把msg变量的值显示到某个DIV元素中
}
//无论Ajax是否成功执行都会触发的回调函数
complete:function(XMLHttpRequest,textStatus){
//隐藏正在查询图片
//window.location.href = location.href;
}
window.location.href = location.href ;
error: function() { alert("error"); }
}
});
}
//异步处理返回数据
//function ajaxCheckRes(data){
//document.getElementById(innerdiv).innerHTML = data;
//}
//重新加载页面
/*function getdigshtml() {
$.ajax({
type:'POST',
url:'customservice.php',
data:'',
success:function(msg){
$("#digg").html(msg);
}
})
}*/
</script>
<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<BODY>
<TABLE cellSpacing=0 cellPadding=0 width="95%" align=center border=0>
<TR height="20">
<TD> </TD>
</TR>
</TABLE>
<table width="95%" align="center" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6">
<tr background="../images/bg.gif" bgcolor="#FFFFFF">
<th scope="row" background="../images/bg.gif" bgcolor="#FFFFFF">开始时间:</th>
<td background="../images/bg.gif" bgcolor="#FFFFFF">
<input id="starttime" onClick="WdatePicker()" type="text" name="starttime" class="textfield"><span style="color: #FF0000">(*)</span>
</td>
<th scope="row" background="../images/bg.gif" bgcolor="#FFFFFF">开始时间:</th>
<td background="../images/bg.gif" bgcolor="#FFFFFF">
<input id="endtime" onClick="WdatePicker()" type="text" name="endtime" class="textfield" onfocus="WdatePicker()"><span style="color: #FF0000">(*)</span>
</td>
</tr>
<tr background="../images/bg.gif" bgcolor="#FFFFFF">
<th colspan="4" scope="row">
<label>
<input type="submit" name="Submit" value="查询医生排期" />
</label>
</form>
</th>
</tr>
</table>
<TABLE cellSpacing=0 cellPadding=0 width="95%" align=center border=0>
<TR height=20>
<TD> </TD></TR>
</TABLE>
<table width="95%" align="center" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6" onMouseOver="changeto()" onmouseout="changeback()">
<tr>
<td width="8%" height="22" background="../images/bg.gif" bgcolor="#FFFFFF"><div align="center">1医生</div></td>
<td width="8%" height="22" background="../images/bg.gif" bgcolor="#FFFFFF"><div align="center">开始时间</div></td>
<td width="8%" height="22" background="../images/bg.gif" bgcolor="#FFFFFF" class="STYLE1"><div align="center">结束时间</div></td>
<td width="5%" height="22" background="../images/bg.gif" bgcolor="#FFFFFF"><div align="center">排期间隔</div></td>
<td width="5%" height="22" background="../images/bg.gif" bgcolor="#FFFFFF"><div align="center">初始号源数</div></td>
<td width="5%" height="22" background="../images/bg.gif" bgcolor="#FFFFFF"><div align="center">剩余号源数</div></td>
<td width="5%" height="22" background="../images/bg.gif" bgcolor="#FFFFFF"><div align="center">是否出诊</div></td>
<td width="5%" height="22" background="../images/bg.gif" bgcolor="#FFFFFF"><div align="center">类别</div></td>
<td width="4%" height="22" background="../images/bg.gif" bgcolor="#FFFFFF"><div align="center">操作员</div></td>
<td width="8%" height="22" background="../images/bg.gif" bgcolor="#FFFFFF"><div align="center">操作</div></td>
</tr>
<?=$strDoctorTime;?>
</table>
<?
}
?>
</BODY>
</HTML>
<?$SqlDB->Close();?>
<script>
$(function() {
$('select').change(function(){
alert(this.name + ':' + $(this).val());
});
});
</script>
<select name=s1><option><option>A<option>B</select>
<select name=s2><option><option>A<option>B</select>
<select name=s3><option><option>A<option>B</select>