tags:

views:

101

answers:

3

Using the code below, I'd like to post or get the value returned (date) into a javascript window so that I can run a query off of the value. Can someone please tell me how to do this?

<form method="post" action="search.html">
  <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;">&nbsp;<img src="calendar.gif" class="cp_img" alt="Open Calendar" style="padding-bottom:3px;"></a><br /><br />
    <input type="submit" name="search" value="Submit">
  </p>
 </form>

Is this just not possible??

A: 

Using the target attribute of <form> will allow you to post data to a new window directly.

<form method="post" action="search.php" target="newpopup">
  <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">
  </p>
 </form>

I am assuming that you are catching the data posted at search.php.

target also accepts _top, _blank, .. so on.

thephpdeveloper
Hi Mauris, Yes, I'm catching the value in the search.php file. This is working fine but once the value is in the search.php file, I need to open another window with the database values. This is where I am stuck.
Also, I don't think that target works with input tags, only the a tag. That I know of anyhow.
Oh... I didn't even notice the mods you made Mauris... Sorry. let me try that. Thanks!
It didn't work. It just opens a new window. I need a javascript window to open.
oh? what's the mod you're talking about?
thephpdeveloper
A: 

using the jQuery Form Plugin you could submit your form ajax-ily, and receive a return success event and values that you could easily pass in querystring of a window.open call and get the result you seek...

Thats just one way...

Another way is not use forms and submits, but just do a ajax post to php service and receive json results and pop up window or thickbox or whatever ..

Scott Evernden
+1  A: 

If you can take your value to search.php, then you could store it in a session variable and recatch it from that session variable in your popup window.

Martin