Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

submit button name/value pairs not set/empty using IE

Status
Not open for further replies.

saroy71

Programmer
May 16, 2002
22
CA
Hi all,

We have a form with two submit buttons each with a unique name/id and value so that we can determine in PHP validation which button was clicked. The form action is the same page for both. That is, the action page must determine which button was clicked and process code accordingly.

Button 1:
Code:
<input type="image" src="/button_update.gif" id="update_submit" name="update_submit" value="true" />

Button 2:
Code:
<input type="image" src="/button_continue.gif" id="create_account_submit" name="create_account_submit" value="true" />

PHP check to see which submit value was passed (clicked):
Code:
if( isset($HTTP_POST_VARS['create_account_submit']) && ($HTTP_POST_VARS['create_account_submit']=='true') )...

This works in all browsers EXCEPT IE6 where the name of the submit button is not set and the value is empty.

What is up with IE? Can you not have name/value pair for a submit button in IE? Will it not send as a POST variable?

Help!
Thanks.
 
I have this problem before. The submit button didn't send it's name and i had to set it manually. I just get in the habit of writing name="submit" and it seems to work out. I hope that's what you were asking. And yes, it is annoying!
 
saroy, IE sucks ass big time! I hate that thing. Unfortunately we have to code for it.

Here is the answer to your problem. I know many people who get this bug and don't know what to do because nobody seems to answer. The problem lies in the 'type="image"' attribute. IE doesn't pass the name/value you use for your image submits so they're useless. Other browsers do so you can properly check as you are doing.

When using an image submit, two other variables are sent in ALL browsers; an 'x' position (var + '.x') and a '.y' position (var + '.y') of where in the image the user clicked. It is these variables that can be checked for in your PHP script since they will be present with all browsers. PHP will convert the .x to '_x' and .y to '_y'.
Therefore, a button with name/id of 'update_submit' can be checked in PHP with the following:
Code:
if( isset($HTTP_POST_VARS['update_submit']) || isset($HTTP_POST_VARS['update_submit_x']) )
{the update submit button was clicked}

Basically you're checking to see if either the 'update_submit' is set (it will be in all browsers other than IE) or 'update_submit_x' is set (it will be in ALL browsers indicating the 'x' coordinate in the image that was clicked). Any button not clicked won't be set.

Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top