mcdougals4all
12-02-2004, 05:45 PM
Javascript seems to treat this the same way. When the button contains no content the value alerts 'set'. When content is added between the button tags the alerted value becomes that content.
Try these examples to see:
<button value="set" name="actionId" onclick="alert(this.value)"></button>
<br />
<br />
<button value="set" name="actionId" onclick="alert(this.value)">OK</button>
You could set the value to the actual text you want and depending on how you're processing the results, script something to the effect: if actionID=OK then someVariable=set.
I was doing this this way because I thought it was ideal for translation. I thought that although the button displayed OK/Cancel, it would always send set/exit so that I wouldn't have to worry about the languages that OK/Cancel would be translated into. This seems like such a simple concept that I'm surprised that things don't work that way. The input tag does the same sillyness in that it displays the value attribute as the text of the button.
I know I could do something like specify different name attribute values
name='set' and name='exit' and then look for the presence of 'set' or 'exit' in the request parameter, but I think that they would both be there. I could also do something goofy with javascript and set some hidden variable, but I was hoping for something cleaner and simpler. Any suggestions?
liorean
12-02-2004, 10:49 PM
Can't you simply take the values 'OK' and 'Cancel' instead? As I understand it, the implementations do the wrong things, but you can accept either the right thing or the thing that browsers actually send server side, in the case they correct their behavior sometime in the future. Make it transparent to the user, don't have to use client side scripting, don't have to use unneccesary HTML elements, and shouldn't put especially high load on the server compared to what you would have otherwise.
Our UI is subject to translation. What if the button text is changed to 'Ja' and 'Nein' (Appologies to anyone who thinks this might resemble german, I have no idea). My servlet would be checking 'OK' and 'Cancel'.
Basically, I went the javascript and hidden variable route.
hemebond
12-03-2004, 11:45 PM
Show us the rest of the form. It sounds to me, like you're going about things the hard way.