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>

解决方案 »

  1.   

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

  2.   

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

  3.   

    demo.htm<input type="button" onclick="window.open('in.htm')" value="Open">
    <input type="text" name="txt" readonly>
    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 window.onload()
    {
        var c = document.form2.chk;
        var strPar = window.opener.document.all.txt.value;
        var arrPar = strPar.split(",")
        for(var i=0;i<arrPar.length;i++)
        {
            for(var k=0;k<c.length;k++)
            {
                if(c[k].value==arrPar[i])c[k].checked=true;
            }
        }
    }       
    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>
      

  4.   

    demo.htm1.<input type="button" onclick="window.open('in.htm','txt1','')" value="Open">
    <input type="text" name="txt1" readonly>
    <br>
    2.<input type="button" onclick="window.open('in.htm','txt2','')" value="Open">
    <input type="text" name="txt2" readonly>
    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 window.onload()
    {
        var c = document.form2.chk;
        //小技巧,利用window.open('in.htm','txt1','')的txt1为window.name
        var strPar = window.opener.document.all[window.name].value;
        var arrPar = strPar.split(",")
        for(var i=0;i<arrPar.length;i++)
        {
            for(var k=0;k<c.length;k++)
            {
                if(c[k].value==arrPar[i])c[k].checked=true;
            }
        }
    }       
    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[window.name].value = arr.join(",");
    }
    </script>
      

  5.   

    留个email,我发个代码例子给你,一样可以实现你需要的功能