请大家帮帮忙 我选择想做一个这样的功能:一个页面(a.jsp)就是有一个文本框,文本框后面有一个查询按钮。点击查询跳到另外一个页面(b.jsp),b.jsp页面有很多html:multibox 选框的选项 ,选择一项点确定后把选择的内容添加到a.jsp页面的那个文本框里。不知道谁有这方面的例子或 代码。给我参照一下,谢谢大家帮帮忙了。等着急用!!!

解决方案 »

  1.   

    a.html
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title></head><body>
    <form id="form1" name="form1" method="post" action="">  <input type="text" name="Text" />  <a href="b.html" target="_blank">b.html</a></form></body>
    </html>
      

  2.   

    b.html<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title><script type="text/javascript" language="javascript">function test(){window.alert('操作成功!');
    window.opener.document.form1.Text.value="test";window.close(this);
    }
    </script></head><body>
    <form id="form1" name="form1" method="post" action="">
      <label>
      <input type="checkbox" name="checkbox" value="checkbox" />
      </label>
      <label>
      <input type="checkbox" name="checkbox2" value="checkbox" />
      </label>
      <label>
      <input type="button" name="button" onclick="test()" value="提交" />
      </label>
    </form>
    </body>
    </html>
    我只是把数据从B.HTML写回A.HTML的文本筐里,具体要怎么样,你自己应该知道怎么做了
      

  3.   

    在b页面选择后点确定把值放在session中,同时刷新a页面,把session中的值输出就可以啊
      

  4.   

    这样跳来跳去,刷新页面可不是什么好的解决方案,我建议使用弹出框,把值返回给主页面,或者采用IFRMAE,将b.jsp赋给IFRAME的SRC,而将此IFRAME置于A.JSP中,点击查询前隐藏
      

  5.   

    使用IFRAME的解决方案,下面是一段使用IFRAME的代码a.jsp<html>
    <script language="javascript">
    function test(my){
    alert(my);
    }
    function ttt(){
    alert('开始调用');
    myframe.document.forms['form1'].button1.onclick();
    myframe.document.forms['form1'].submit();
    }
    </script>
    <body>
    <br>ppp
    <br>
    <br>
    <iframe src="includehtml.html" id="myframe"> 
    </iframe> <br>
    <br>
    <br>
    <input type="button" value="调用子窗体按钮的事件" onclick = "javascript:ttt()">
    </body>
    </html>
      

  6.   

    includehtml.html(b.jsp)<html>
    <body>
    <form id = "form1" action = "dd.htm">
    <input type="button" id="button1" value="引用" onclick="parent.test('我是谁')">
    </form>
    </body>
    </html>
      

  7.   

    这个写的确实好用a.html
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title></head><body>
    <form id="form1" name="form1" method="post" action="">  <input type="text" name="Text" />  <a href="b.html" target="_blank">b.html</a></form></body>
    </html>b.html<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title><script type="text/javascript" language="javascript">function test(){window.alert('操作成功!');
    window.opener.document.form1.Text.value="test";window.close(this);
    }
    </script></head><body>
    <form id="form1" name="form1" method="post" action="">
      <label>
      <input type="checkbox" name="checkbox" value="checkbox" />
      </label>
      <label>
      <input type="checkbox" name="checkbox2" value="checkbox" />
      </label>
      <label>
      <input type="button" name="button" onclick="test()" value="提交" />
      </label>
    </form>
    </body>
    </html>
      

  8.   

    a.jsp
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title></head>
    <%
    String value = request.getParameter("a");
    if(value == null){
     value = "";
    }
    %>
    <body>
    <form id="form1" name="form1" method="post" action="">  <input type="text" name="Text" value="<%=value%>">  <a href="b.html" target="_blank">b.html</a></form></body>
    </html>
    b.jsp<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title><script type="text/javascript" language="javascript">function test(){window.alert('操作成功!');
    window.form1.submit();
    window.close(this);
    }
    </script></head><body>
    <form id="form1" name="form1" method="post" action="a.jsp">
      <label>
      <input type="checkbox" name="a" value="111" />
      </label>
      <label>
      <input type="checkbox" name="a" value="222" />
      </label>
      <label>
      <input type="button" name="button" onclick="test()" value="提交" />
      </label>
    </form>
    </body>
    </html>
      

  9.   

    用JAVASCRIPT就可以了1.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <META NAME="Generator" CONTENT="EditPlus">
      <META NAME="Author" CONTENT="">
      <META NAME="Keywords" CONTENT="">
      <META NAME="Description" CONTENT="">  <script language="javascript">  </script>
     </HEAD> <BODY>
    <textarea id="text" cols="10" rows="5"></textarea>
    <input type="button" value="open" onclick="window.open('2.html')"/>
     </BODY>
    </HTML>
    2.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <META NAME="Generator" CONTENT="EditPlus">
      <META NAME="Author" CONTENT="">
      <META NAME="Keywords" CONTENT="">
      <META NAME="Description" CONTENT="">
      <script language="javascript">
    function change() {
    var str = "";
    var arr = document.forms[0].elements;
    for (var i = 0;i<arr.length;i++ )
    {
    if (arr[i].checked)
    {
    str += arr[i].value+"\r\n";
    }
    } window.opener.document.getElementById("text").value = str;
    }
      </script>
     </HEAD> <BODY>
     <form>
      <input type="checkbox" name="chk" value="a"/>a
      <input type="checkbox" name="chk" value="b"/>b
      <input type="checkbox" name="chk" value="c"/>c
      <input type="checkbox" name="chk" value="d"/>d
      <input type="checkbox" name="chk" value="e"/>e
      <input type="checkbox" name="chk" value="f"/>f
      <input type="checkbox" name="chk" value="g"/>g
      </form>
      <input type="button" value="changeValue" onclick="change()"/>
     </BODY>
    </HTML>