views:

1031

answers:

2

With my PHP form, I want to pass one value to the URL, but remove submit.x and submit.y. Here's my form:

<form action="booking.php" method="get">    
<input type="image" value="access" class="rollbtn" src="../images/book-btn.gif" alt="Book" name="submit" />
</form>

I want the URL to display booking.php?submit=access - but omit the x and y coordinates that result from the type="image". If I add onsubmit="this.submit();return false;" it strips everything. Is there a way to do this, or should I just use type="submit" and style the button?

+3  A: 

You have a few of options.

  1. Input type submit with src of an image;
  2. Input type submit with CSS background image; or
  3. Image submit that submits with Javascript;

Image submits are meant so you can get the coordinates of where was clicked. It might matter on image maps.

cletus
+1  A: 

You could use:

<button type="submit"><img src="../images/book-btn.gif" alt="Book" /></button>

and then use appropriate CSS to remove the button element's default styling such as borders.

NickFitz
Just remember that in IE6/IE7 you will get this garbage on the URL: submit=<img%20src="../images/book-btn.gif"%20alt="Book"%20/>(this was fixed in IE8 for the record)
scunliffe
NickFitz, your code has an Empty tag notation. Pick one or the other. :)
epascarello
@epascarello: it's HTML 5, where that is valid HTML markup - cutting edge ;-)
NickFitz