We help IT Professionals succeed at work.

Pass Texbox Value to a Query String in HTML

p-plater used Ask the Experts™
I have a popup HTML page that is activated with jarvascript, on the popup is a textbox and a submit button, I need to get the value that is entered in the Textbox into the Query String of the Submit Button.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If you are using a <form> this is automatic, either by POST or by GET, depending on what you specify the method to be:

<form method="GET" action="http://yoursite.com/process.php">
<textarea name="textbox">Content</textarea>
<input type="submit" value="submit" />

This form upon submission would access the webpage




This the form code.

<form name="wishlist_pop_add" action="http://localhost/web_sites/tfs/test/index.php?main_page=wishlist&cPath=33&products_id=1950&action=un_add_wishlist" method="post">

This is the Submit Button code.

<input type="image" src="includes/templates/tfstheme/buttons/english/wishlist_add.gif" alt="Add to Wish List" title=" Add to Wish List " onClick="window.close()" />

It works fine on my local Machine but when I try it on a remote server the "Action" form receives no POST variables.
When I remove the onClick="window.close()" it works but the popup stays open.
Should I be closing the Popup a different way?
You can try taking out the onClick on the submit and setting the onsubmit on the form:

<form name="wishlist_pop_add" action="http://localhost/web_sites/tfs/test/index.php?main_page=wishlist&cPath=33&products_id=1950&action=un_add_wishlist" method="post" onsubmit="window.close();">


Same Result - Works Localy but not on Remote Server.

<form name="wishlist_pop_add" action="http://localhost/web_sites/tfs/live/index.php?main_page=wishlist&cPath=7_122&sort=20a&products_id=657&action=un_add_wishlist" method="POST" onsubmit="window.close()">

<input type="image" src="includes/templates/tfstheme/buttons/english/wishlist_add.gif" alt="Add to Wish List" title=" Add to Wish List " />

Hmm.  You could pass the window id to the PHP file and execute the window.close from there.

How do you have your window.open set up?

You could maintain the window handle in the parent like this:

parent.windowHandle = window.open('http://www.yoursite.com','windowName','height=640,width=480');

then close it using



Sorry but how do I execute the "parent.windowHandle.close();  " from the PHP file?
// Your PHP code goes here
<script type="text/javascript">

// more PHP


Doesn't close the popup.

My Window open is.

function session_win(url) {
  parent.windowHandle = window.open(url,"popup_wishlist_add","height=300,width=400,toolbar=no,statusbar=no,directories=yes,scrollbars=yes,screenX=150,screenY=150,top=250,left=150").focus();
Sorry, it appears security issues are preventing the execution of this javascript.

I'm afraid the only other thing I can suggest is to put an arbitrary delay on the closure of the window so that the form has time to submit:

<form name="wishlist_pop_add" action="http://localhost/web_sites/tfs/test/index.php?main_page=wishlist&cPath=33&products_id=1950&action=un_add_wishlist" method="post" onsubmit="setTimeout('window.close',5000);">

Project Lead
see what I can say is .. . you have a type=image for your submit button so it may not work... try using type=submit .. it should work on the remote server as well....  you can have a image on the submit button by using some css class....

and if you want to close the window only use this ...


Open in new window


Thanks for your Help