因为我必须取iframe中的checkbox的Value值以后才能提交,现在的问题是无法取得iframe中的checkbox的值

解决方案 »

  1.   

    <form name=form1 method=post action="myjsp.jsp">
    <iframe id=myiframe src="about:<input type=checkbox name=mycheckbox value=mycheckbox>"></iframe>
    <input type=button value=submit onclick="alert(myiframe.mycheckbox.checked);form1.submit()">
    </form>
      

  2.   

    好像不行,你那个about后面的是什么意思呢?
    页面会出现myiframe.mycheckbox.checked不是对象的错误
      

  3.   

    不会啊,我运行很正常啊。scr="about:..."引号中为指定的iframe页面文件名,我这样写只是为了代码简单。你再试试
      

  4.   

    如果没有同名的checkbox,用数组报错
      

  5.   

    我是个菜鸟呀,为什么说i没有定义呀!!
    我的表单名为FrmList
    Iframe的ID为List
    checkbox的名字为List
    对了,checkbox不止一个,有很多,是同名不同值的
      

  6.   

    <form name=FrmList method=post action="myjsp.jsp">
    <iframe id=List
     src="about:<input type=checkbox name=mycheckbox value=1><input type=checkbox name=mycheckbox value=2><input type=checkbox name=mycheckbox value=3>"></iframe>
    <input type=button value=submit onclick="mysubmit()">
    </form>
    <script>
    function mysubmit()
    {
    for(i=0;i<List.mycheckbox.length;i++)
    {
    alert(List.mycheckbox[i].checked);
    alert(List.mycheckbox[i].value);
    }
    FrmList.submit();
    }
    </script>
      

  7.   

    将checkbox的名字改为List也是一样
      

  8.   

    我的页面是这样的,可就是不行呀!! 
    <form name="frmList" method="post" action="Customer_Del.asp">
            <table width="100%" border="0" cellspacing="0" cellpadding="1">
              <tr> 
                <td valign="middle"> 
                  <div align="right"><a href="#"><img src="images/Customer_Add.gif" width="87" height="18" border="0" onClick="MM_openBrWindow('Customer_Add.asp','','width=400,height=335,resizable=no ,help=yes')"></a> 
                    <input type="image" border="0" name="imageField" src="images/Customer_Del.gif" width="87" height="18" onclick="mysubmit()">
    <script>
    function mysubmit()
    {
    for(i=0;i<List.mycheckbox.length;i++)
    {
    alert(List.mycheckbox[i].checked);
    alert(List.mycheckbox[i].value);
    }
    FrmList.submit();
    }
    </script>
                  </div>
                </td>
              </tr>
            </table>
    <iframe ID=List Name=List src="Customer_Files.asp" Width="100%" height="180px" scrolling="Auto" FrameBorder="1"></iframe>        
    </form>
      

  9.   

    把Customer_Files.asp的代码贴出来
      

  10.   

    checkbox如果同名的有不止一个,则可直接用formname.checkbox.value
    如有不止一个则用document.all[checkboxname]取得,我写了一个函数你用用看吧!如下
    //--- 方法名: getCheckedString(AFormName,AChkName,ADivStr)
    //--- 功能: 取得单选框中的值
    //--- 返回: 选中单选框的值,如没有选中返回"";
    //---     AFormName: 所在的Form名
    //---     AChkName: CheckBox列表的名 
    //---     ADivStr: 分割字符串
    //--- 创建日期:     2002-04-10  最近更新日期:   2002-04-10
    //--- 创建程序员:     xg_delayth  最近更新程序员: xg_delayth
      function getCheckedString(AFormName,AChkName,ADivStr){
        var collection,i,tmpValue="";
        try{
          collection=document.all[AChkName];
          if (1<collection.length){
            for (i=0;i<collection.length;i++){
              if (true==collection[i].checked && collection[i].value!=""){
                tmpValue=tmpValue+collection[i].value+ADivStr;
              }
            }
            if (""!=tmpValue) return tmpValue.substring(0,tmpValue.lastIndexOf(ADivStr));
            else return "";
          } else{
            if (eval(AFormName+"."+AChkName+".checked")){
              return eval(AFormName+"."+AChkName+".value");
            } else{
              return "";
            }
          }
        } catch(e){
          return "";
        }
      }
      

  11.   

    <form name="FrmList" method="post" action="Customer_Del.asp">
            <table width="100%" border="0" cellspacing="0" cellpadding="1">
              <tr> 
                <td valign="middle"> 
                  <div align="right"><a href="#"><img src="images/Customer_Add.gif" width="87" height="18" border="0" onClick="MM_openBrWindow('Customer_Add.asp','','width=400,height=335,resizable=no ,help=yes')"></a> 
                    <input type="image" border="0" name="imageField" src="images/Customer_Del.gif" width="87" height="18" onclick="mysubmit()">
    <script>
    function mysubmit()
    {
    for(i=0;i<List.frmList.mycheckbox.length;i++)//frmList为iframe中form名
    {
    alert(List.frmList.mycheckbox[i].checked);
    alert(List.frmList.mycheckbox[i].value);
    }
    if((i==0)&&(List.frmList.mycheckbox!=null))//当只有一个checkbox时
    {
    alert(List.frmList.mycheckbox.checked);
    alert(List.frmList.mycheckbox.value);
    }
    FrmList.submit();
    }
    </script>
                  </div>
                </td>
              </tr>
            </table>
    <iframe ID=List Name=List src="Customer_Files.asp" Width="100%" height="180px" scrolling="Auto" FrameBorder="1"></iframe>        
    </form>