用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();
}

解决方案 »

  1.   

    复选框的ID是递增的[我从数据库读出.你也可以指定相同的名称用document.getElementsByName来返回集合对象.]然后用
    document.all.FieldID.value=window.showModalDialog('','','')就可以了.
      

  2.   

    demo.htm<input type="button" onclick="window.open('in.htm')" value="Open">
    <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的页面中的复选框限制只能选一次,
    怎么处理,
      

  3.   

    数字金刚的方法基本上可以满足要求。对于另外2个问题:
    1、“每个复选框有一个值”,如果是指只能有一个选项被选中,那么请用radio框,如果是指至少有一个被选中,则应该用javascript判断,如果要设置缺省值,请用“check”属性;
    2、可以在被操作一次后用javascript将该元素设为无效,就可以不能再被修改了
      

  4.   

    一般涉及到很多的选项,比较复杂的,用checkbox,比较好