最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Remove submit.x and submit.y but retain other values in URL - Stack Overflow

programmeradmin6浏览0评论

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?

Share Improve this question edited Aug 7, 2009 at 10:55 NickFitz 35.1k8 gold badges45 silver badges41 bronze badges asked Aug 7, 2009 at 10:18 strangerpixelstrangerpixel 8281 gold badge12 silver badges27 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

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.

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".

发布评论

评论列表(0)

  1. 暂无评论