This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

submit button problem in IE

 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have 2 butttons on a form. 1 submits the order and the other submits calculate Shipping
WHen i log the results on the server side no matter which button i press they are null

This same code works fine in the latest firefox

am i missing something?

TIA John


Form code


Server Code
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John,
I've never seen a value attribute on an image/submit button before. Have you tried using a hidden field to send the value to the server and just use the image tag for the actual submit?
 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but then how would i know which button was pressed? I am using an image instead of the generic looking button.
As far as I know thats the only way to do it
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:John,
I've never seen a value attribute on an image/submit button before.

The name/value pair of an input type="image" or input type="submit" or button type="submit" element can be used at the server side to distinguish the button pressed. Useful if you've multiple submit buttons in one form. Filling a hidden field and manipulating it with JS is just cumbersome.

Back to actual problem: IE has the behaviour that in case of an input type="image" it will append the name with ".x" and ".y" to represent the position of the mouse cursor at the image.

You can solve it by either using CSS background property to picture a button instead, or to not only check for parameter "name", but also "name.x" if a specific button is pressed.
 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:
Jeanne Boyarsky wrote:John,
I've never seen a value attribute on an image/submit button before.

The name/value pair of an input type="image" or input type="submit" or button type="submit" element can be used at the server side to distinguish the button pressed. Useful if you've multiple submit buttons in one form. Filling a hidden field and manipulating it with JS is just cumbersome.

Back to actual problem: IE has the behaviour that in case of an input type="image" it will append the name with ".x" and ".y" to represent the position of the mouse cursor at the image.

You can solve it by either using CSS background property to picture a button instead, or to not only check for parameter "name", but also "name.x" if a specific button is pressed.


so if i use the css for the BG image how would i make the actual submit button transparent?

thanks for the help
john
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an example CSS rule from one of my apps that uses background images for the buttons:


 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, so i tried the .x on the parameter name in my servelt and that seemed to work. i did this as it was the quickest solution.
One thing to note is the name doesnt seem to matter on the server side. it just comes back as a number and the button that was not pressed is just null.
So the only limitation i see is that you cant compare names. Its either null or not null. so i guess in the case of having more than 2 buttons to compare this would not work and the best bet would be using the background image.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Schretz wrote:ok, so i tried the .x on the parameter name in my servelt and that seemed to work. i did this as it was the quickest solution.
One thing to note is the name doesnt seem to matter on the server side. it just comes back as a number and the button that was not pressed is just null.
The CSS solution is preferred.


So the only limitation i see is that you cant compare names. Its either null or not null. so i guess in the case of having more than 2 buttons to compare this would not work and the best bet would be using the background image.
I don't see why you can't use more than 2 buttons. To check if a certain button is pressed, just check if its name/value pair is present in the request parameter map. If you use image buttons only and assign them all the same name, then it isn't going to work in IE. But if you use normal submit buttons, then you can assign them all the same name and a different value and in the server side you could check by only the name which button is pressed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic