Forum Moderators: coopster

Message Too Old, No Replies

Image submit button and enter/return key

With an image button to submit a form, the enter/retun keys don't work

         

ro1960

9:05 am on Apr 3, 2007 (gmt 0)

10+ Year Member



I recently discovered that when using an image submit button, the button name was not passed as such, but the coordinates of the click on the image were appended to it.

With this button:

<input type="image" src="images/go_round_white.gif" value="go!" name="searchparties_advanced">

the variables passes are searchparties_advanced.x and searchparties_advanced.y

PHP doesn't like periods in variable names so it converts them to underscores, so in my form process page I have:

if ($_POST['searchparties_advanced_x'])
{
....MYSQL QUERY....
}

and this works fine.

However if the user hits the return or enter key to submit the form, the MYSQL query returns an error.

I tried to add a hidden field to my form like this:

<input name="alt_btn" type="hidden" value="searchparties_advanced">

and change my if statement in my process page to this:

if (($_POST['searchparties_power_x']) OR ($_POST['alt_btn'] == "searchparties_advanced"))

but it doesn't work.

How can I get BOTH the click on the image and the return/enter key to submit the form correctly?

Thanks.

jatar_k

3:04 pm on Apr 3, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld ro1960,

have you tried just dumping the $_POST array to see what happens when they hit enter? is nothing at all sent?