js改变ID值
<script>
var object = new Object();
function t_onchange(obj){
var s = document.getElementById("s1").value;
var k = document.getElementById("s2").value;
if(typeof(object[s])=='undefined'){
object[s] = {};
}
if(typeof(object[s][k])=='undefined') object[s][k]=new Object();
object[s][k][obj.id]=obj.value;
}
function s_change(){
for(var i=1;i <57;i++){
document.getElementById(i).checked=false;
}
var s = document.getElementById("s1").value;
var k = document.getElementById("s2").value;
if(typeof(object[s])!='undefined'){
if(typeof(object[s][k])!='undefined'){
for(var i in object[s][k]){
document.getElementById(i).checked=object[s][k][i];
}
}
}
}
</script>
<table>
<tr>
<td>
第 <select name="week" id="s1" onChange="s_change()">
<%
for i=1 to 18
response.Write " <option value='"&i&"'>"&i
NEXT
%>
</select>周
</td>
<td>
第 <select name="zu" id="s2" onChange="s_change(this)">
<%
for i=1 to 10
response.Write " <option value='"&i&"'>"&i
NEXT
%>
</select>台
</td>
</tr>
<tr> <td> </td> </tr>
<tr>
<td colspan="3">
<table border="1" align="center" width="100%" bordercolor="#d5fcfc">
<tr> <td width="60px" > </td> <td width="50px" >星期一 </td> <td width="50px">星期二 </td> <td width="50px" >星期三 </td> <td width="50px" >星期四 </td> <td width="50px" >星期五 </td> <td width="50px" >星期六 </td> <td width="50px">星期日 </td> </tr>
<tr> <td width="60px">第1、2节 </td>
<% for a=1 to 7
response.Write" <td width='50px'> <input type='checkbox' name='"&a&"' id='1_1_b"&a&"' onClick='t_onchange(this)'> </td>"
next
%>
</tr>
<tr> <td width="60px">第3、4节 </td>
<% for b=8 to 14
response.Write" <td width='50px'> <input type='checkbox' name='"&b&"' id='1_1_b"&b&"' onClick='t_onchange(this)'> </td>"
next
%> </tr>
<tr> <td width="60px">第5、6节 </td>
<% for c=15 to 21
response.Write" <td width='50px'> <input type='checkbox' name='"&c&"' id='1_1_b"&c&"' onClick='t_onchange(this)'> </td>"
next
%> </tr>
<tr> <td width="60px">第7、8节 </td>
<% for d=22 to 28
response.Write" <td width='50px'> <input type='checkbox' name='"&d&"' id='1_1_b"&d&"' onClick='t_onchange(this)'> </td>"
next
%> </tr>
<tr> <td width="60px">第9、10节 </td>
<% for e=29 to 35
response.Write" <td width='50px'> <input type='checkbox' name='"&e&"'' id='1_1_b"&e&"' onClick='t_onchange(this)'> </td>"
next
%> </tr>
<tr> <td width="60px">第11、12节 </td>
<% for f=36 to 42
response.Write" <td width='50px'> <input type='checkbox' name='"&f&"' id='1_1_b"&f&"' onClick='t_onchange(this)'> </td>"
next
%> </tr>
<tr> <td width="60px">第13、14节 </td>
<% for g=43 to 49
response.Write" <td width='50px'> <input type='checkbox' name='"&g&"' id='1_1_b"&g&"' onClick='t_onchange(this)'> </td>"
next
%> </tr>
<tr> <td width="60px">第15、21节 </td>
<% for h=50 to 56
response.Write" <td width='50px'> <input type='checkbox' name='"&h&"' id='1_1_b"&h&"' onClick='t_onchange(this)'> </td>"
next
%>
</table>
</td>
</tr>
</table>
在这个基础上,如何实现:
当我选了第二周,第一台,第一二节,其checkbox的id值会变成2_1_b(1-56)
当我选了第二周,第四台,第一二节,其checkbox的id值会变成2_4_b(1-56)
当我选了第五周,第三台,第一二节,其checkbox的id值会变成5_3_b(1-56)
。。。。。。。。。。。。。。。。
不好意思,没什么分了!请高手见谅!
[解决办法]
兄弟你分真多啊~~
狂轰滥炸解决不了问题,有这些零散分提问还不如加到一个帖子里呢。