如何使用java脚本在struts 1.2中将值从子页面传递到showmodelgialoge中的父页面

时间:2015-12-27 13:04:21

标签: javascript jquery struts-1

单击boo按钮时,打开showmodeldialoge并检查showmodeldialoge中的某行,当按foo按钮无法从子页面获取值并传递到父页面时

父页面代码:

function explain() {
//newwin = window.open('domain.do?method=showBranchForm','newwin');

var a='domain.do?method=showBranchForm';
window.showModalDialog(a, self, 'status:no;resizable:yes;help:no;scroll:yes;width:1300;height:600');

}


<input <%=branchEnable%> class="btn"
style="width: 120px" value="boo" type="button"
onclick="explain();" />

子值应显示在此处:

<select id="listbranch"
multiple="multiple" size="8" name="listbranch"
style="width: 200px; font-family: tahoma; font-size: 16"/>

这是子页面:

<script language="javascript" type="text/javascript">
    function TransferData() 
    {
       opener.window.document.forms[0].elements['listbranch'].length=0;
       counter=0;
        document.forms.newform.elements
        for(i=0; i<document.forms[0].elements.length; i++)
        {
        if(document.forms[0].elements[i].type=="checkbox")
        {
            if(document.forms[0].elements[i].checked==true)
        {
            opener.window.addOption(document.forms[0].elements[i].value,document.forms[0].elements[i].id,counter); 
            counter++;
        }
        }
  }
 window.close();
}
</script>





 <tbody>
                                    <%
                                        if(branchsIterator != null){
                                            while(branchsIterator.hasNext()){
                                            Branch t = branchsIterator.next();
                                    %>
                                        <tr>
                                            <td><input type="checkbox"  id="<%=t.getBranchCode()%>"  value="<%=t.getBranchName() %>"/></td>
                                            <td ><%=t.getBranchName() %></td>
                                            <td><%=t.getBranchCode() %></td>
                                        </tr>
                                        <%} 
                                        }
                                        %>
                                    </tbody>


<input class="btn" type="button" value="اfoo" style="width:200px" onclick="TransferData();" />

0 个答案:

没有答案