a.jsp 父页面文本框输入name,到b.jsp子页面执行SQL查询name相关的一条数据放在b.jsp的列表框里,点击b.jsp 列表框的值传给a.jsp,
要实现a.jsp的列表框无刷新添加b.jsp传的值。

解决方案 »

  1.   

    parent.xxxfrm.xxtext.value = 'a';
      

  2.   

    父页面 写一个JS方法,供子页面调用,把子页面的值以参数形式传到父页面处理,子页面调用父页面的方法有window.parent.addItem(value),window.opener.addItem(value),假设 addItem(value) 是父页面写的方法,这里处理往父页面添加 从子页面传来的值,可以是一个值,可是是一个数组;往列表框中添加一个选项的举例:
    function addItem(value){
      if(value != ""){
        document.form.list.length++; 
        document.form.list.options[document.form.list.length - 1].text = value;
        document.form.list.options[document.form.list.length - 1].value = value;
      }else{
        alert("请填写内容");
      }
    }
      

  3.   

    子页面查询返回后用window.opener引用父页面内容
      

  4.   

        <script language="javascript">
        //全局变量 存放线路名称
        var _xlmc;
    function passtofather(){
     var myTable=window.opener.document.getElementById("tdsbfwtable");

    var xlmcObj = document.getElementsByName("xlmcs");
    var dydj = $("dydj").value;
    dydj = dydj/1000;
    for(i=0;i<xlmcObj.length;i++)
    {
    if (xlmcObj[i].checked)
    {
    var nowCheckBoxValue =xlmcObj[i].value;
    // 添加一行。
    var oRow1=myTable.insertRow(myTable.rows.length); // 获取表格的行集合。
    var aRows=myTable.rows;
    // 获取第一行的单元格集合。
    var aCells=oRow1.cells; //可不可以这样呢?--可以的  !#################################
    //aCells.length为零。
    var oCell1_1=oRow1.insertCell(aCells.length); //aCells.length为一。---因为添加了一个cell了,aCells集合长度自动加1;
    var oCell1_2=oRow1.insertCell(aCells.length);
    var oCell1_3=oRow1.insertCell(aCells.length);
    var oCell1_4=oRow1.insertCell(aCells.length);
    var oCell1_5=oRow1.insertCell(aCells.length);
    // 为 2 个新单元格添加规范的 HTML 值。
    oCell1_1.innerHTML="<input type=\"text\" name=\"tdsbfw_tmp\" value="+nowCheckBoxValue+"  style=\"border: 1px solid #FFFFFF;width=120px\"" +" readonly>";
    oCell1_2.innerHTML="<input type=\"text\" name=\"dydjStr\" value="+dydj+"  style=\"border: 1px solid #FFFFFF;width=80px\"" +" readonly>";
    oCell1_3.innerHTML="<input type=\"text\" name=\"miaoshu\" value=\"\"  style=\"font-size: 9pt;HEIGHT:18px;border: 0;border: solid 1px #888888;background-color: #ffffdd;width=140px\">";
    oCell1_4.innerHTML="<input type=\"text\" name=\"jutineirong\" value=\"\"  style=\"font-size: 9pt;HEIGHT:18px;border: 0;border: solid 1px #888888;background-color: #ffffdd;width=360px\">";
    //oCell1_4.innerHTML="<textarea name=\"jutineirong\" class=\"text\"></textarea>";
    oCell1_5.innerHTML="<input type=\"button\" name=\"delete\" value=\"删除\"  class=\"button\" onclick=\"javascript:deleteThisRow(this);\">";

    }
    }

      window.close();}
      

  5.   

    <input type="button" name="button_1" id="button_1" value="确定并关闭" class="button" onclick="passtofather();">
      

  6.   


    首先非常感谢你提供的方法!
    现在的问题是,我在父页输入name开口子页面查询的时候,父页就自动刷新,然后列表框中的值就没有了!!怎么能让打开子页时,不自动刷新呢!!