用showModalDialog的returnValue
function SetRole()
{
var strRoleIDList="";
var strValue="";
try
{
for(iIndex=0;iIndex<document.all.length;iIndex++)
{
if(document.all(iIndex).type=="checkbox")
{
if(document.all(iIndex).checked==true)
{
strValue=document.all(iIndex).id;
strRoleIDList=strRoleIDList+strValue.substr(strValue.indexOf("RoleID")+6)+",";
}
}
}
window.returnValue=strRoleIDList.substr(0,strRoleIDList.length-1);
}
catch(e)
{}
window.close();
}
function SetRole()
{
var strRoleIDList="";
var strValue="";
try
{
for(iIndex=0;iIndex<document.all.length;iIndex++)
{
if(document.all(iIndex).type=="checkbox")
{
if(document.all(iIndex).checked==true)
{
strValue=document.all(iIndex).id;
strRoleIDList=strRoleIDList+strValue.substr(strValue.indexOf("RoleID")+6)+",";
}
}
}
window.returnValue=strRoleIDList.substr(0,strRoleIDList.length-1);
}
catch(e)
{}
window.close();
}
document.all.FieldID.value=window.showModalDialog('','','')就可以了.
<input type="text" name="txt">in.htm<form name="form2">
1.<input type="checkbox" name="chk" value="1">
2.<input type="checkbox" name="chk" value="2">
3.<input type="checkbox" name="chk" value="3">
4.<input type="checkbox" name="chk" value="4">
5.<input type="checkbox" name="chk" value="5">
<br>
<input type="button" onclick="ChangeText()" value="添加">
</form>
<script>
function ChangeText()
{
var c = document.form2.chk;
var arr = new Array();
for(var i=0;i<c.length;i++)
{
if(c[i].checked)arr[arr.length]=c[i].value;
}
window.opener.document.all.txt.value = arr.join(",");
}
</script>
如果,在IN.HTM的页面中的复选框限制只能选一次,
怎么处理,
1、“每个复选框有一个值”,如果是指只能有一个选项被选中,那么请用radio框,如果是指至少有一个被选中,则应该用javascript判断,如果要设置缺省值,请用“check”属性;
2、可以在被操作一次后用javascript将该元素设为无效,就可以不能再被修改了