你像通过谁(radio,checkbox)的onclick事件获取?
解决方案 »
- ie6不支持JSON.parse方法该如何是好
- 请教,fancybox调用页面后,页面里的button点击后无反应,如何解决
- jquery如何取第一级子tr标签(多层表格)
- 如何获取光标位置处是哪个对象及光标位置处的文本的样式?
- 火狐浏览器支持document.getElementById吗?
- GridView中文本框怎样修改只读形式
- 有关text域值自动对应以及disabled表单动作捕捉的问题。
- 怎么在javascript里判断一个treeview的节点为子节点?
- 如何使下面的例子中的内容显示多于10条信息,在线等待,谢谢各位高手!
- js入门
- 请教:javaScript中如何得到table的当前行?
- 50分急求判断“数据库字段是否为空的问题”
function a123()
{
for(i=0;i<document.all.a1.length;i++)
{
if(document.all.a1[i].checked)
{
alert(document.all.a1[i].value)
}
}
for(i=0;i<document.all.b1.length;i++)
{
if(document.all.b1[i].checked)
{
alert(document.all.b1[i].value)
}
}
}
</script>
<input name=a1 type=radio checked value=1>
<input name=a1 type=radio value=2>
<input name=a1 type=radio value=3>
<input name=a1 type=radio value=4>
<input name=a1 type=radio value=5>
<input name=a1 type=radio value=6>
<input name=b1 type=checkbox value=1>
<input name=b1 type=checkbox value=2>
<input name=b1 type=checkbox value=3>
<input name=b1 type=checkbox value=4>
<input name=b1 type=checkbox value=5>
<input name=c1 type=button onclick=a123() value="得到值">
测试过,可以的
html-----------------
<table>
<tr>
<td>
<input type="radio" name="rad1" value="r1" onclick="fncChecked()">
<input type="radio" name="rad1" value="r2" onclick="fncChecked()">
<input type="radio" name="rad1" value="r3" onclick="fncChecked()">
<input type="radio" name="rad1" value="r4" onclick="fncChecked()">
<input type="radio" name="rad1" value="r5" onclick="fncChecked()">
</td>
<td>
<input type="checkbox" name="che1" value="c1">
<input type="checkbox" name="che1" value="c2">
<input type="checkbox" name="che1" value="c3">
<input type="checkbox" name="che1" value="c4">
<input type="checkbox" name="che1" value="c5">
</td>
</tr>
</table>
javascript-------------------
function fncChecked()
{
var rads=document.MyForm.rad1.length;
var ches=document.MyForm.che1.length;
var temp="";
for(i=0;i<rads;i++)
{
if(document.MyForm.rad1[i].checked)
{
temp=temp+"radio:"+document.MyForm.rad1[i].value+";";
for(j=0;j<rads;j++)
{
if(document.MyForm.che1[j].checked)
{
temp=temp+"checkbox:"+document.MyForm.che1[j].value+",";
}
}
}
}
alert(temp);
}
可用