how to stop reloading parent window while child window gets open
I have a form submit, where it get the values from the form and goes
to next page… here I have a hyperlink to open a child window, while
I click, it opens the child window and simultaneously it reloads the
parent window. I have a action configured to the parent window which
has a Database insert statement too.The problem is that while I click the link it call my action
again(because of page reload), in this action I wrote if condition to
check null/empty string from the previous page form submit. since this
is the second time the action loads it looks of the fields(but
actually those fields are in my previous page form). so it take null
while checking my if condition.Another problem is that when I solve the above problem here comes the
SQL insert statement, which is about to execute 2nd time. I dont want
this to happen or I dont want my action to execute while I open the
popup window and I want to populate the selected value from the popup
to the parent window.
用于打开弹出窗口的代码
1
2 3 4 5 |
function select_reactant()
{ window.open ("SeriesTab.action?component=reactant", "mywindow","scrollbars=1,resizable=1,width=1000,height=1000"); }; |
这是我打开弹出窗口并希望将从弹出窗口中选择的值填充到此处的文本文件的地方
1
2 3 4 |
<tr>
<td>reactant</td> <td><s:textfield name="reactant" id="reactantId" readonly="true" theme="simple"/></td> </tr> |
jquery 将值表单弹出返回到父窗口
1
|
$(window.opener.document).find(‘#reactantId’).val(rxn);
|
下面action里面的代码就是我开头提到的那个action
1
2 3 4 |
if(Rxn!=null||!Rxn.equals("")) //Rxn is the field variable for previous page
{ //my insert statement } |
当我运行时,我得到空指针错误,因为 Rxn 的值在页面重新加载时被重置为 null,因为
完成了弹出窗口打开
1
|
window.open
|
你可以这样做
HTML
1
|
reactant
|
jQuery
1
2 3 4 5 6 |
$(function(){
$("#anchSelectReactant").click(function(){ select_reactant(); return false; }); }); |
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/268741.html