问题:一个新增页面,其中客户名称:【文本框】文本框旁边有个查询超链接,点击超链接进入查询页面,查询完后点击单条记录在返回新增页面中的客户名称的文本框中。新增页面中部分代码: <td width="15%" align="right"><font color="RED" size="2">*</font>抵押单位名称:</td>
            <td width="35%" class="fieldname"><html:text property="pledgeDydwmc" styleClass="inputtext" onkeydown="dealEnter();"/>
           <a  href="/CAPledgeCusNameAction.do?action=query" target="_blank">
           查询
           </a>
            </td>
查询页面: <td align="middle"><%=(((Integer)request.getAttribute("pageNumber")).intValue() - 1) * ((Integer)request.getSession().getAttribute("perNum")).intValue() + recordNumber.intValue()+1%></td>
     <td><bean:write name="item" property="cus_cd"/></td>
<td><bean:write name="item" property="cus_name_cn"/></td>
怎么把<bean:write name="item" property="cus_name_cn"/>的值在传回新增页面的文本框中。

解决方案 »

  1.   

    A页面有文本框和一个查询超链接,点击查询超链接时跳转到B页面进行查询,查询后点击单条数据把名称返回给A页面的文本框中
      

  2.   

    回跳的时候经过一个.do吧,把数据放到form中,这个就简单了
      

  3.   

    放到URL中通过GET方式传递不行吗?
      

  4.   

    呵呵,我知道只是个值传递,问题是怎么B页面中选中了直接传递给前面A打开的页面
    A页面里特地target="_blank"打开一个新的页B,传回来怎么我也希望互不耽误。各位程序看下。
      

  5.   

    用 window.open() 打开页面。 在打开的页面关闭前,用 window.opener.form名称.元素名.value 赋值
      

  6.   

    具体咋写的啊?
    我昨天open里打开action处理点了按钮没反应
      

  7.   

    昨天这么做,点击按钮的时候没反应,后来换成的<a>直接跳转到下一个页面
      

  8.   

    function  ChangeCusName(){
      window.open("/CAPledgeCusNameAction.do?action=query","抵押单位名称查询","height=100,width=400,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no";) 
      document.forms[0].submit();
      }
      

  9.   

    就是我刚才说的那种方式就可以了,表单不用提交的。你在原页面用window.open打开。在被打开的页面里可以通过 window.opener得到打开页面的表单元素。从而对其进行赋值。明白了吗?
      

  10.   

    struts里标签都没有name属性,js不知道咋用标签的name属性的,不是很熟悉这个东西,能否给个小例子,我也在边看边试
      

  11.   

    你这个东西得用ajax要不弹出页面咋执行查询还能返回当前页面.
    首先用var s=window.showModalDialog("b.html"); 
    打开查询页面,查询页面用AJAX执行后台返回结 果,关闭这个窗口的时候执行这个方法
    window.returnValue="查询结果"; 
    self.close(); 
    然后文本框中用S赋值
      

  12.   

    我以前是这样做的,LZ试试,我还没有测试:<td width="15%" align="right"><font color="RED" size="2">*</font>抵押单位名称:</td>
                        <td width="35%" class="fieldname"><html:text property="pledgeDydwmc"         styleClass="inputtext" onkeydown="dealEnter();" styleId="entName" />
                          <a  href="/CAPledgeCusNameAction.do?action=query" target="_blank">
                          查询
                          </a>
                        </td>
    <SCRIPT language="javascript">
       function test(entName)
    {
    window.dialogArguments.(这里要写你A页的表单).entName.value = Trim(entName);
    window.close();
    }
    </SCRIPT>
    <td align="middle"><%=(((Integer)request.getAttribute("pageNumber")).intValue() - 1) * ((Integer)request.getSession().getAttribute("perNum")).intValue() + recordNumber.intValue()+1%></td>
            <td><bean:write name="item" property="cus_cd"/></td>
            <td><bean:write name="item" property="cus_name_cn"/></td>
            <td>
        <a href="javascript:onClick=test('<bean:write name="item" property="cus_name_cn"/>')">选择</a>
    </td>

      

  13.   

    曾经这么用过  A页面----你的新增页面<SCRIPT language="javascript">
      function doOurTeam(){var projectId = document.getElementById("projectId").value;
        var returnValuee=showModalDialog("<htmlex:cp/>//exploit.ourteam.search.do?projectId="+projectId,window,"status:false;dialogWidth:550px;dialogHeight:500px;help:no;status:no");
        document.forms[0].ourTeam.value="";  
        document.forms[0].ourTeam.value=returnValuee;
    }
    </SCRIPT>B页面----你的查询页面<SCRIPT language="javascript">
    function onOk(){
      var selected= document.forms[0].checkbox;  
      var returnVal="";
      for(var i=0;i<selected.length;i++){
        if(selected[i].checked==true){
         if(returnVal==""){
         returnVal = selected[i].value;
         }else{
         returnVal=returnVal+" "+selected[i].value;
           }
          
        }
      }
     window.returnValue=returnVal;
     window.close();
    }</SCRIPT>B页面直接调用onOk() 方法回写A页面对应的内容!OVER!
      

  14.   

    补充下:
    window.showModalDialog( url, window ); 
    然后在弹开窗口中: 
    window.dialogArguments 即为父窗口window对象的引用,注意第二个参数用window,这样你就把父窗口对象当做参数传递给了子窗口.
    然后在子窗口中就可以通过window.dialogArguments来引用父窗口对象了.
      

  15.   

    今天试了一个方法:
    A页面:
    <tr class="sysdisplay">
                <td width="15%" align="right"><font color="RED" size="2">*</font>抵押单位名称:</td>
                <td width="35%" class="fieldname"><html:text property="pledgeDydwmc" styleClass="inputtext" onkeydown="dealEnter();"/>
               <input type="button" value="..." onclick="ChangeCusName();">
                </td>
                <td width="15%" align="right"></td>
                <td width="35%" class="fieldname"></td>
    </tr>function  ChangeCusName(){
    window.open('/cAPledgeCusNameAction.do?action=query','抵押单位名称查询','height=800,width=800,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no'); 
       document.forms[0].submit();
    }B页面:
    <td>
    <a onclick="subm()">
    <div id="idname">
    <bean:write name="item" property="cus_name_cn"/>
    </div>
    </a>
    </td>

    function subm(){ 
    window.opener.document.getElementById('pledgeDydwmc').value=document.getElementsById("idname").innerText; 
    window.close(); 
    }问题:如果我的window.opener.document.getElementById('pledgeDydwmc').value=8;
    这样都是对的。
    应该是我获取不到bean:write name="item" property="cus_name_cn"的值
    function cusm(){ 
    alert("aaaa");
    alert(document.getElementById('cus_name_cn').value);
    alert(document.getElementsById("cusnamecn").innerHTML.toString());
    window.opener.document.getElementById('pledgeDydwmc').value=8;
    window.close();
    }
    只有第一条打印aaaa,后面两天既不报错也没反应,请问各位什么原因啊?
      

  16.   

    用js写这样的代码,在A页面上定义个变量数组,用于接收参数
    var array=new Array(1);
    var returnName=window.open("B.aspx",array);
    if(returnName==null)
    {
     return;
    }
    else
    {
      this.document.getElementById("textbox1").value=returnName[0];
    }在B页面中
    var array=new Array(1);
    array[0]="需要返回的名称";
    window.parent.returnValue=array;
    window.parent.close();可以这样试试,呵呵
      

  17.   

    呵呵,其实我的需求已经满足了,用opener,现在的问题是我获取不到bean:write name="item" property="cus_name_cn"的内容?
      

  18.   

     window.dialogArguments.document.forms[0].entName.value = Trim(entName);
     window.close();我的方法获取不到?
      

  19.   

    完整代码:
    B页面:
    <a href="javascript:onClick=test('<bean:write name="item" property="cus_name_cn"/>')">
    <td>
    <bean:write name="item" property="cus_name_cn"/>
    </td>
    </a>function test(entName){
    window.opener.document.getElementById('pledgeDydwmc').value=entName;
    window.close();
    }
    A页面:
    <tr class="sysdisplay">
                <td width="15%" align="right"><font color="RED" size="2">*</font>抵押单位名称:</td>
                <td width="35%" class="fieldname"><html:text property="pledgeDydwmc" styleClass="inputtext" onkeydown="dealEnter();"/>
               <input type="button" value="..." onclick="ChangeCusName();">
                </td>
                <td width="15%" align="right"></td>
                <td width="35%" class="fieldname"></td>
    </tr>function  ChangeCusName(){
    window.open('/cAPledgeCusNameAction.do?action=query','抵押单位名称查询','height=800,width=800,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no'); 
       document.forms[0].submit();
    }谢谢各位了,不过div的那种方式我还是没获取到
      

  20.   

    17楼正解。
    页面A:触发点击事件,事件处理时:var returnValue=window.showModalDialog("b.html");
    然后,document.getElementById("文本框").innerText= returnValue;
    页面B:进行正常的数据处理完,比较笨方式的Response.write("<script>window.returnvalue=" +  处理结果 + " ;window.close();</scritp>")
      

  21.   

    可以在超链接页面这样写,window.parent.document.getElementById("txt").value = document.getElementById("tt").value;
    当前页面就有值了。
      

  22.   

    用网页地址传递简单方便,如:a.jsp?p1=abc   在a.jsp中就可以使用request.getParameter("p1");得到参数值“abc”
      

  23.   

    你在传递页面的时候顺道把值传过去啊,然后在新页面接受URL的值就可以了啊
      

  24.   

    href="/CAPledgeCusNameAction.do?action=query" 
    这是什么啊?struct1啊。。后面跟action干嘛啊
      

  25.   

    用JSP做很简单
    查询页面:
    <a href="a.jsp?id=<%=‘传的值’>"></a>
    显示页面:
    接收=request.getParameter("id");
    根据写的dao类查询语句把结果显示出来