codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  posting values from pop up window to parent window  callmaxim at 01:15 on Monday, September 15, 2003
 

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?

  Re: posting values from pop up window to parent window  Troy Wolf at 04:50 on Tuesday, September 16, 2003
 

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.
Troy Wolf: site expert
Shiny Solutions


  Re: posting values from pop up window to parent window  arsum2 at 22:45 on Friday, January 02, 2004
 

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

  Re: posting values from pop up window to parent window  Troy Wolf at 02:58 on Saturday, January 03, 2004
 

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();
}
Troy Wolf: site expert
Shiny Solutions


  Re: posting values from pop up window to parent window  arsum2 at 00:57 on Monday, January 05, 2004
 

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,


  Re: posting values from pop up window to parent window  vinayak_hebbar at 08:59 on Wednesday, October 27, 2004
 

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

  Re: posting values from pop up window to parent window  Troy Wolf at 15:28 on Wednesday, October 27, 2004
 

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";
Troy Wolf: site expert
Shiny Solutions









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: posting values from pop up window to parent window
•  Testing file for type of data
•  Running VB6 application as a ASP.NET application
•  login system with asp.net
•  Re: Help: Trouble with z-Index and SELECT lists
•  What is wrong with this ASP codes? It don`t seem to work???
•  Need help with ListBox control
•  Re: Good Javascript/DHTML Reference
•  Re: scrolling table


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2004