for(i=0;i<=49;i++){
eval("document.formtest.gdchw_zh"+i+".value")=eval("top.document.zhuanhuan.gdchw"+i+".value")
}//这样

解决方案 »

  1.   

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>test</title>
    <script language="javascript">
    <!--
    function chuanzhi()
    {
    document.formtest.mbch_zh.value=top.document.zhuanhuan.mbch.value;
    document.formtest.gdsl_zh.value=top.document.zhuanhuan.gdsl.value;for(i=0;i<eval(document.formtest.gdsl_zh.value);i++)
    {
    eval("document.formtest.gdchw_zh"+i+".value")=eval("top.document.zhuanhuan.gdchw"+i+".value");
    }
    }
    -->
    </script></head><body onLoad="javascript:chuanzhi();">
    <form name="formtest" method="post" action="test.asp">
    <input type="text" name="mbch_zh" id="mbch_zh" value="">
    <input type="text" name="gdsl_zh" id="gdsl_zh" value=""><br><br><input type="text" name="gdchw_zh0" id="gdchw_zh0" value=""><br>
    <input type="text" name="gdchw_zh1" id="gdchw_zh1" value=""><br>
    <input type="text" name="gdchw_zh2" id="gdchw_zh2" value=""><br>
    <input type="text" name="gdchw_zh3" id="gdchw_zh3" value=""><br>
    <input type="text" name="gdchw_zh4" id="gdchw_zh4" value=""><br>
    <input type="text" name="gdchw_zh5" id="gdchw_zh5" value=""><br>
    <input type="text" name="gdchw_zh6" id="gdchw_zh6" value=""><br>
    <input type="text" name="gdchw_zh7" id="gdchw_zh7" value=""><br>
    <input type="text" name="gdchw_zh8" id="gdchw_zh8" value=""><br>
    <input type="text" name="gdchw_zh9" id="gdchw_zh9" value=""><br>
    <input type="text" name="gdchw_zh10" id="gdchw_zh10" value=""><br>
    <input type="text" name="gdchw_zh11" id="gdchw_zh11" value=""><br>
    <input type="text" name="gdchw_zh12" id="gdchw_zh12" value=""><br>
    </form>
    </body>
    </html>麻烦帮我看看,为什么我还是得不到数据呢??document.formtest.mbch_zh.value=top.document.zhuanhuan.mbch.value;
    document.formtest.gdsl_zh.value=top.document.zhuanhuan.gdsl.value;可以得到数据,其它的还是不行哦,麻烦帮我看看啊,谢谢了!!!
      

  2.   

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>test</title>
    <script language="javascript">
    <!--
    function chuanzhi()
    {
    document.formtest.mbch_zh.value=top.document.zhuanhuan.mbch.value;
    document.formtest.gdsl_zh.value=top.document.zhuanhuan.gdsl.value;for(i=0;i<parseInt(document.formtest.gdsl_zh.value);i++)
    {
    eval("document.formtest.gdchw_zh"+i+".value")=eval("top.document.zhuanhuan.gdchw"+i+".value");
    }
    }
    -->
    </script></head><body onLoad="javascript:chuanzhi();">
    <form name="formtest" method="post" action="test.asp">
    <input type="text" name="mbch_zh" id="mbch_zh" value="">
    <input type="text" name="gdsl_zh" id="gdsl_zh" value=""><br><br><input type="text" name="gdchw_zh0" id="gdchw_zh0" value=""><br>
    <input type="text" name="gdchw_zh1" id="gdchw_zh1" value=""><br>
    <input type="text" name="gdchw_zh2" id="gdchw_zh2" value=""><br>
    <input type="text" name="gdchw_zh3" id="gdchw_zh3" value=""><br>
    <input type="text" name="gdchw_zh4" id="gdchw_zh4" value=""><br>
    <input type="text" name="gdchw_zh5" id="gdchw_zh5" value=""><br>
    <input type="text" name="gdchw_zh6" id="gdchw_zh6" value=""><br>
    <input type="text" name="gdchw_zh7" id="gdchw_zh7" value=""><br>
    <input type="text" name="gdchw_zh8" id="gdchw_zh8" value=""><br>
    <input type="text" name="gdchw_zh9" id="gdchw_zh9" value=""><br>
    <input type="text" name="gdchw_zh10" id="gdchw_zh10" value=""><br>
    <input type="text" name="gdchw_zh11" id="gdchw_zh11" value=""><br>
    <input type="text" name="gdchw_zh12" id="gdchw_zh12" value=""><br>
    </form>
    </body>
    </html>
    这个页面是一个内嵌的框架页面,准备从主框架中获取数据,数据的数量有四种可能10,20,30,50我想跟着主框架参数的变化,我要在当前框架中显示相同数量的文本框和隐藏域两种控件(以备后面的数据提交),请教有什么好的方法么??谢谢了
    麻烦帮我看看,为什么我得不到数据呢??
    document.formtest.mbch_zh.value=top.document.zhuanhuan.mbch.value;
    document.formtest.gdsl_zh.value=top.document.zhuanhuan.gdsl.value;可以得到数据,其它的还是不行哦,麻烦帮我看看啊,谢谢了!!!
      

  3.   

    <form action="" method="post" name="zhuanhuan">
    <input name="mbch" type="hidden" value="<%=request.Form("mubiao")%>">
    <input name="gdsl" type="hidden" value="<%=request.Form("gdsm")%>">
    <%  for i=0 to (request.Form("gdsm")-1)   %><input name="gdchw<%=i%>" type="hidden" value="<%=request.Form("h_word"&i)%>"><%  next   %>
    </form>
    <table width="437" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td colspan="2">&nbsp;</td>
              </tr>
              <tr>
                <td width="20">&nbsp; </td>
                <td align="left">词汇测试&nbsp;&gt;&gt;<%=ss%><%=tt%></td>
                </tr>
              <tr>
                <td colspan="2">

    <iframe id="frmceshi" width="430" height="300" scrolling="yes" frameborder="1" style="" src="test.asp"></iframe>


    </td>
                </tr>
            </table>主框架代码太多了,我只贴了一部分相关的代码,这部分经过测试了,是没有问题的,数据输出都是正确的。原本考虑从主框架传到内嵌的框架,但是几乎行不通哦,主框架的语句太多了;只有考虑从内嵌框架接收数据了,谢谢帮忙啊!!
      

  4.   

    晕死,没见过这样设计的.
    <body onLoad="javascript:chuanzhi();">
    这样top获得的全是""
    点击form再把值传给top吧
    <form name="formtest" method="post" action="test.asp" onSubmit="chuanzhi();">
      

  5.   

    还有:
    <input name="mbch" type="hidden" value="<%=request.Form("mubiao")%>">
    <input name="gdsl" type="hidden" value="<%=request.Form("gdsm")%>">
    <%  for i=0 to (request.Form("gdsm")-1)   %><input name="gdchw<%=i%>" type="hidden" value="<%=request.Form("h_word"&i)%>"><%  next   %>request.Form("h_word"&i)根本有用
      

  6.   

    哦,我看错了
    原来你是想从主框架中获取数据.以为你把iframe 的数据传给主框架;<input name="gdchw<%=i%>" type="hidden" value="<%=request.Form("h_word"&i)%>">
    你必须保证有值
      

  7.   

    回楼上的我在使用top的时候,
    document.formtest.mbch_zh.value=top.document.zhuanhuan.mbch.value;
    document.formtest.gdsl_zh.value=top.document.zhuanhuan.gdsl.value;<input type="text" name="mbch_zh" id="mbch_zh" value="">
    <input type="text" name="gdsl_zh" id="gdsl_zh" value="">这个是通过的啊,能得到值的。很奇怪哦还有,我把
    hidden改为text后,能得到数据的,说明 request.Form("h_word"&i) 是可行的哦!
    <input name="gdchw<%=i%>" type="hidden" value="<%=request.Form("h_word"&i)%>">最后,
    我还是不知道如何循环获得
    文本框输出哦,
      

  8.   

    <form name="formtest" method="post" action="test.asp" onSubmit="chuanzhi();">这个是直接传递参数,而不要其它事件触发么??
    能直接调用内嵌框架内的子程序么???
      

  9.   

    下面的应该合你的要求吧:
    index.htm
    _________________________________
    <form name="form1" method="post" action="index.asp">
        <p>
            <input type="text" name="mubiao">
            <br>
            <input type="text" name="gdsm">
            <br>
        <input type="text" name="h_word0">
    <br>
        <input type="text" name="h_word1">
        <br>
        <input type="text" name="h_word2">
        <br>
        <input type="text" name="h_word3">
        <br>
        <input type="text" name="h_word4">
        <br>
        <input type="text" name="h_word5">
      </p>
        <p>
          <input type="submit" name="Submit" value="提交">
          <br>
            </p>
    </form>____________________________________________________________index.asp__________________________________________________________<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><form action="" method="post" name="zhuanhuan">
    <input name="mbch"  value="<%=request.Form("mubiao")%>">
    <input name="gdsl"  value=<%=request.Form("gdsm")%>>
    <%  for i=0 to (request.Form("gdsm")-1)   %><input name="gdchw<%=i%>"  value="<%=request.Form("h_word"&i)%>"><%  next   %>
    </form>
    <table width="437" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td colspan="2">&nbsp;</td>
              </tr>
              <tr>
                <td width="20">&nbsp; </td>
                <td align="left">词汇测试&nbsp;&gt;&gt;<%=ss%><%=tt%></td>
                </tr>
              <tr>
                <td colspan="2">

    <iframe id="frmceshi" width="430" height="300" scrolling="yes" frameborder="1" style="" src="test.asp"></iframe>


    </td>
                </tr>
            </table>
    _________________________________________________________________________________________
    test.asp
    _______________________________________________________________________________________<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>test</title>
    <script language="javascript">
    <!--
    function chuanzhi()
    {
    document.formtest.mbch_zh.value=top.document.zhuanhuan.mbch.value;
    document.formtest.gdsl_zh.value=top.document.zhuanhuan.gdsl.value;
    var i;
    for(i=0;i<parseInt(document.formtest.gdsl_zh.value);i++)
    {
    eval("document.formtest.gdchw_zh"+i+".value=top.document.zhuanhuan.gdchw"+i+".value");
    }
    }
    -->
    </script></head><body onLoad="javascript:chuanzhi()">
    <form name="formtest" method="post"  >
    <input type="text" name="mbch_zh" id="mbch_zh" value="">
    <input type="text" name="gdsl_zh" id="gdsl_zh" value=""><br><br><input type="text" name="gdchw_zh0" id="gdchw_zh0" value=""><br>
    <input type="text" name="gdchw_zh1" id="gdchw_zh1" value=""><br>
    <input type="text" name="gdchw_zh2" id="gdchw_zh2" value=""><br>
    <input type="text" name="gdchw_zh3" id="gdchw_zh3" value=""><br>
    <input type="text" name="gdchw_zh4" id="gdchw_zh4" value=""><br>
    <input type="text" name="gdchw_zh5" id="gdchw_zh5" value=""><br>
    <input type="text" name="gdchw_zh6" id="gdchw_zh6" value=""><br>
    <input type="text" name="gdchw_zh7" id="gdchw_zh7" value=""><br>
    <input type="text" name="gdchw_zh8" id="gdchw_zh8" value=""><br>
    <input type="text" name="gdchw_zh9" id="gdchw_zh9" value=""><br>
    <input type="text" name="gdchw_zh10" id="gdchw_zh10" value=""><br>
    <input type="text" name="gdchw_zh11" id="gdchw_zh11" value=""><br>
    <input type="text" name="gdchw_zh12" id="gdchw_zh12" value=""><br>
    </form>
    </body>
    </html>
      

  10.   

    leo963258(读书之人)
    给你的:eval("document.formtest.gdchw_zh"+i+".value")=eval("top.document.zhuanhuan.gdchw"+i+".value")是错误的!!!!!
    因为是不能给函数负值的.eval("document.formtest.gdchw_zh"+i+".value=top.document.zhuanhuan.gdchw"+i+".value")才对.唉,什么是时候都是眼大睇过龙了.
      

  11.   

    weinierxing(一根火柴):
    我都说看错了.
    ____________________________________
    能直接调用内嵌框架内的子程序么???
    _____________________________________可以!还有贴代码出来,若有2页以上,都应该说明哪个是什么文件,哪个是什么文件的.方便别人看/理解你的意图
      

  12.   

    YES!
    谢谢你的帮忙了,搞定了,谢谢了!!还有哦,我想同样把<input type="text" name="gdchw_zh0" id="gdchw_zh0" value=""><br>
    <input type="text" name="gdchw_zh1" id="gdchw_zh1" value=""><br>
    <input type="text" name="gdchw_zh2" id="gdchw_zh2" value=""><br>
    <input type="text" name="gdchw_zh3" id="gdchw_zh3" value=""><br>
    <input type="text" name="gdchw_zh4" id="gdchw_zh4" value=""><br>
    <input type="text" name="gdchw_zh5" id="gdchw_zh5" value=""><br>
    <input type="text" name="gdchw_zh6" id="gdchw_zh6" value=""><br>
    <input type="text" name="gdchw_zh7" id="gdchw_zh7" value=""><br>
    <input type="text" name="gdchw_zh8" id="gdchw_zh8" value=""><br>
    <input type="text" name="gdchw_zh9" id="gdchw_zh9" value=""><br>
    <input type="text" name="gdchw_zh10" id="gdchw_zh10" value=""><br>
    <input type="text" name="gdchw_zh11" id="gdchw_zh11" value=""><br>
    <input type="text" name="gdchw_zh12" id="gdchw_zh12" value="">搞个循环,数量就是上面传入的数值 document.formtest.gdsl_zh.value ,我又不知道怎么弄哦,pansiom(pansiom):
    你说的对,下次,我一定注意问问题的方式,会加注释的!
      

  13.   

    不是吧
    改eval("document.formtest.gdchw_zh"+i+".value=top.document.zhuanhuan.gdchw"+i+".value");
    就是了.
    eval("document.formtest.gdchw_zh"+i+".value=document.formtest.gdsl_zh.value");因为document.formtest.gdsl_zh.value=top.document.zhuanhuan.gdsl.value;
    所以也可以eval("document.formtest.gdchw_zh"+i+".value=top.document.zhuanhuan.gdsl.value");不过这样不好,每次都得访问top.
      

  14.   

    我的意思是把带数据的文本框循环输出,数量就是 document.formtest.gdsl_zh.value 可以直接就在表单里面循环么??<form name="formtest" method="post"><input type="text" name="gdchw_zh0" id="gdchw_zh0" value="">
    .
    .
    .</form>因为我对javascript就是不太明白,劳您费大神了,呵呵,谢谢了!
      

  15.   

    可以用Write([string])/WriteLine([string])
    <form name="formtest" method="post">
    <input type="text" name="gdchw_zh0" id="gdchw_zh0" value=""><br>
    <input type="text" name="gdchw_zh1" id="gdchw_zh1" value=""><br><script>
    var tem=top.document.zhuanhuan.gdsl.value;
    for(var i=0;i<parseInt(tem);i++)
    {
    WriteLine("<input type='text' name='gdchw_zh'"+i+" id='gdchw_zh'"+i+" value='"+tem+"'><br>");
    }
    </script>
    </form>
      

  16.   

    document.write("<input type='text' name='gdchw_zh'"+i+" id='gdchw_zh'"+i+" value='"+tem+"'><br>");调试成功但是还是接收不到数据,可能存在这个脚本后执行的原因吧??
      

  17.   

    有了WriteLine("<input type='text' name='gdchw_zh'"+i+" id='gdchw_zh'"+i+" value='"+tem+"'>改为
    document.write("<input type='text' name='gdchw_zh"+i+"' id='gdchw_zh"+i+"'value='"+tem+"'>单引号的位置,改了,搞定了