关于checkbox选中后显示值的问题(通用js)
2006-09-29 16:29
543 查看
<script language=javascript>
function check()
{
//alert(Form1.chkbiz_model.value);
for(var i=0;i<document.Form1.elements.length;i++)
{
//if (document.Form1.elements[i].type=="checkbox"){
if (document.Form1.elements[i].name=="chkbiz_model")
{
if(document.Form1.elements[i].checked == true) alert(document.Form1.elements[i].value);
//document.Form1.elements[i].checked=t;
}
}
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="0" width="90%" border="0">
<tbody>
<tr>
<td width="24%" height="25"><input type="checkbox" value="生产型" name="chkbiz_model">
生产型
</td>
<td width="24%" height="25"><input type="checkbox" value="贸易型" name="chkbiz_model">
贸易型
</td>
<td width="24%" height="25"><input type="checkbox" value="服务型" name="chkbiz_model"> 服务型
</td>
<td width="28%" height="25"><input type="checkbox" value="政府或其他机构" name="chkbiz_model">
政府或其他机构
</td>
</tr>
</tbody>
</table>
<P><INPUT type="button" value="Button" onclick="check()"></P>
</form>
function check()
{
//alert(Form1.chkbiz_model.value);
for(var i=0;i<document.Form1.elements.length;i++)
{
//if (document.Form1.elements[i].type=="checkbox"){
if (document.Form1.elements[i].name=="chkbiz_model")
{
if(document.Form1.elements[i].checked == true) alert(document.Form1.elements[i].value);
//document.Form1.elements[i].checked=t;
}
}
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="0" width="90%" border="0">
<tbody>
<tr>
<td width="24%" height="25"><input type="checkbox" value="生产型" name="chkbiz_model">
生产型
</td>
<td width="24%" height="25"><input type="checkbox" value="贸易型" name="chkbiz_model">
贸易型
</td>
<td width="24%" height="25"><input type="checkbox" value="服务型" name="chkbiz_model"> 服务型
</td>
<td width="28%" height="25"><input type="checkbox" value="政府或其他机构" name="chkbiz_model">
政府或其他机构
</td>
</tr>
</tbody>
</table>
<P><INPUT type="button" value="Button" onclick="check()"></P>
</form>
相关文章推荐
- 关于BaseAdapter,SimpleAdapter的数据显示错乱问题,选中状态错乱问题,Checkbox选中状态错乱问题总结
- 用隐藏域解决关于checkbox 不选中传值问题
- js判断checkbox选中(记录一下,一个小问题引发的)
- 关于用js和attr("selected",true);给select设置选中的值失效问题
- 关于GridView的模板列中有CheckBox的分页显示问题
- 关于ext2.2.1rdadio和checkbox不能正常显示的问题解决方法
- ie中js创建checkbox默认选中问题
- 初学者 的 js 关于checkbox全选的问题
- IE中radio 或checkbox的checked属性初始状态下不能选中显示问题
- 关于用js和attr("selected",true);给select设置选中的值失效问题
- ie中js创建checkbox默认选中问题
- ie中js创建checkbox默认选中问题探讨
- 关于JS动态显示的中文乱码问题
- jquery关于checkbox选中和不选中的问题
- struts2标签:关于radio,checkbox返回值选中的问题
- 关于ListView+CheckBox,Item超过一屏时数据乱序和不能全部选中的问题
- 关于用js和attr("selected",true);给select设置选中的值失效问题
- 关于checkbox 不选中传值问题
- JS实现表单中checkbox对勾选中增加边框显示效果
- JS实现表单中checkbox对勾选中增加边框显示效果