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?
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 Answers
Reset to default 4You have a few of options.
- Input type submit with src of an image;
- Input type submit with CSS background image; or
- 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.
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.
I ran into a similar need, I solved it using jQuery doing something like this:
<script src="where_you_have_jquery.js"></script>
<script>
$('#my_form').submit(function(){
$('#submit_img').attr('disabled',true);
});
</script>
Your submit image has to have "submit_img" (in this case) as its id attribute, for this to work. And your form id="my_form".