tags:

views:

67

answers:

3

I need to get the value from the parent form into the child; not the other way around. Found many a howto from child to parent but that doesn't work for me. I have an onclick event in the input button but I'm unsure how to get the value from this calendar into the child window from here.

<form method="post" action="">
  <p style="padding:10px;">
    <input type="text" id="date" name="date" value="" maxlength="10"><a href="javascript:void(0);" onclick="g_Calendar.show(event, 'date', 'yyyy-mm-dd')" title="Show Calendar" style="text-decoration:none;"> <img src="calendar.gif" class="cp_img" alt="Open Calendar" style="padding-bottom:3px;"></a><br /><br />
    <input type="submit" name="search" value="Submit" onclick="popWindow('search.php')">
  </p>
 </form>
A: 

You can use QueryStrings like this -

<input type="submit" name="search" value="Submit" onclick="popWindow('search.php')">

You can read the QueryString values using utilities like this one.

EDIT

function popWindow(windowUrl) {
    var dateVal = document.getElementById("date").value;
    window.open(windowUrl + "?dateValue=" + dateVal); //This will open the window with the URL like search.php?dateValue=1/1/09.
}
Kirtan
Hi Kirtan, thanks. Will the value of the date input be appended **before** the user presses the button or afterward? If it is afterward, this won't work. At least I don't think it will.
Kirtan.. Thank you! I at least have the value in the window now. I have another question if you wouldn't mind. I already have a javascript script to open a window. Can I replace your window.open code and replace it with my code and still have it work or is the window.open needed?
Kirtan, thank you. I got it! Thank you! I really have to learn some javascript.
A: 

If you are opening a window using window.open you can pass value to it using

  1. Querystring

like

search.php?ValueToPass=value

and read from the popup using

Request.QueryString["ValueToPass"]

or read value from pop up using

window.opener object.

This returns a reference to the window that opened this current window.

Eg:

window.opener.document.getElementById('<%=text.ClientID%>').value

Edit:

From PHP you can get the querystring variable. Take a look at

PHP $_GET Function

rahul
Hi Phoenix and thanks for the help. I think that Kirtan is suggesting the same thing. Yes, I'm using window.open but my question is: will the value of the date calendar be appended after or before the user presses the submit button?
Also, it seems to me that if I can append a querystring onto the filename, I dhould be able to use PHP to test for the GET var. Yes?
Yes you can access the querystring variable in PHP.
rahul
phoenix, thanks for all the help!
A: 

sry wrong posting !!!!!