checkbox和radio一样,将name设为相同才能发挥其最大用处 var c=document.form1.chbox for(i=0;i<c.length;i++) ...要不可以用 var c=document.getElementsByTagName("input") for(i=0;i<c.length;i++) if(c.type=="checkbox") ...
checkbox和radio一样,将name设为相同才能发挥其最大用处 var c=document.form1.chbox for(i=0;i<c.length;i++) ...我K,还有这个用法,我原来也是,设为相同的名字,但只是用来向后台传,这回要在页面上,学习ing
{
var tepcheckvalue = ""; // document.form_total.bbmb.value=bbmb;
// document.form_total.bmid.value=bmid;
i=0;
document.form_total.bblist.value="";
for(i=0;i<cnt_check;i++)
{
tempcheck = document.all('checkbox' + i) ;
if(tempcheck.checked==true)
{
tepcheckvalue = tepcheckvalue+"@"+tempcheck.value;
}
}
alert(tepcheckvalue);
document.form_total.bblist.value = tepcheckvalue;
document.form_total.target="_blank";
document.form_total.action="submitReportForAccount.jsp";
document.form_total.submit();
return;
}
tempcheck = eval(checkbox + i);
这样应该就可以了。
var c=document.form1.chbox
for(i=0;i<c.length;i++)
...要不可以用
var c=document.getElementsByTagName("input")
for(i=0;i<c.length;i++)
if(c.type=="checkbox")
...
var c=document.form1.chbox
for(i=0;i<c.length;i++)
...我K,还有这个用法,我原来也是,设为相同的名字,但只是用来向后台传,这回要在页面上,学习ing
{
var tepcheckvalue = ""; // document.form_total.bbmb.value=bbmb;
// document.form_total.bmid.value=bmid;
var c=document.form_total.checkbox ;
for(i=0;i<c.length;i++) {
// tempcheck = document.all('checkbox' + i)
// tempcheck = eval(document.form_total.checkbox + i );
//alert(i + tempcheck ) ;
// if(c.checked==true)
// {
// alert(i + tempcheck ) ;
tepcheckvalue = tepcheckvalue+"@"+c.value;
// }
}
alert(tepcheckvalue);
没好使,
怎么回事??
<script language="JavaScript">
<!--
function s(){
var str=""
var c=document.frm.a
for(i=0;i<c.length;i++)
if(c[i].checked)str+=c[i].value
alert(str)
}
//-->
</script>
<form name=frm>
<input type="checkbox" name="a" value="是">
<input type="checkbox" name="a" value="这">
<input type="checkbox" name="a" value="样">
<input type=submit onclick="s()">
</form>