|
I am trying to pass values from a pop up window to the main window that popped this child window , with the idea to have the parent window refresh itself with value from pop up window. But the values are not going through (actually it works in html, but in PHP format I get 'undefined' value in the string).
The following is the code I have.
Main:
<script language=javascript>
function GetReason() {
var winWidth = 300;
var winHeight = 300;
var winLeft = (screen.width-winWidth)/2;
var winTop = (screen.height-winHeight)/2;
win1 = window.open("reason.html", "Reason", +
"menubar=0,toolbar=0,resizable=1,scrollbars=1" +
",width=" + winWidth + ",height=" + winHeight +
",top="+winTop+",left="+winLeft);
}
function SetReason(reasonText) {
document.forms[0].reasonText.value = reasonText;
document.forms[0].submit();
}
</script>
<form>
<input type=hidden name=reasonText>
<input type=button name="btntype" value="Disapprove Leave" onclick="GetReason()">
</form>
POP UP:
<script language=javascript>
function SubmitReason() {
window.opener.SetReason(document.forms[0].reasonText.value);
self.close();
}
</script>
<body onload=self.focus()>
<form>
<input name=reasonText type=radio value="Max">
<br><input type=button value="Submit" onclick="SubmitReason()">
</form>
What is the problem?
|
|
|
This code looks very familiar....I think I posted very similar code in this forum previously--glad you could use it! 
I don't notice any problems glancing over the code. You say it works in HTML, but not in the PHP. If the value IS getting passed back into the parent page--which you can easily test with a javascript alert() before you submit the form, then the problem is not in this code, but in your server-side PHP. If in fact a javascript alert shows that you are getting your value into the parent page form's element ok, then post your PHP issue in the PHP forum and see if you can get some help. I'm not qualified to help with PHP, but I do a little PHP.
|
|
|
|
|
Hello,
I saw your message regarding "posting values from pop up window to parent window.
From your code, I am able to get one value from child window. How to get more than one values from checkbox.
Thank you in advance.
arsum
|
|
|
I'm not exactly sure I understand your question, but given the sample code, if you wanted to have the popup window pass 3 values back, for example, modify the code like this:
Popup Window Code:
window.opener.SetReason(document.forms[0].reasonText.value, document.forms[0].field2.value, document.forms[0].field3.value); |
|
Then in the main page (the parent page):
function SetReason(reasonText, value2, value3) {
document.forms[0].reasonText.value = reasonText;
document.forms[0].SomeOtherField.value = value2;
document.forms[0].A_Third_Field.value = value3;
document.forms[0].submit();
} |
|
|
|
|
|
|
Thank you for your reply.
Actually, I am using jsp files. I am getting records from a database and printing them in a child window. I am printing records using for loop.
Example:
<table>
<%
for(int i =0; i <5; i++)
{
%>
<tr>
<td><input name=ckname type=checkbox value="<%=database value%>">Fruits
</td>
</tr>
<% } %>
</table>
User selects few records(using check box) and press "Select" button. Upon select, the main window should display the selected records.
My question is, how to get the values of selected records from child window to parent window.
Thanks,
|
|
|
hi arsum2,
i got the smae problems like you. I am using jsp page and i am using javascript for poping up the window. Now i want to pass some parameters from popupwindow to parent window.
I need some guidance on this, if u got the answer for your question then please let me know how to do it.
thanks in advance,
vinayak hebbar
|
|
|
Your child window javascript can access the parent objects simply by prefixing self.opener to the object reference.
So if your parent window has a javascript variable named ParentWindowColor, then your child window could do this:
self.opener.ParentWindowColor = 'green';
In the same way, if your parent window had a javascript function called fnDoSomething(), your child window could call it like so:
self.opener.fnDoSomething();
Likewise, if your parent window had a form named "MyForm" with an input element named "FirstName", your child window could do:
self.opener.document.MyForm.FirstName.value = "Marklar";
|
|
|
|
|
|
|
|
|
|