Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>button value not being sent

button value not being sent

wac
12-02-2004, 05:19 PM
I've got two buttons

<button type="submit" name='actionID' value='set'>OK</button>
<button type="submit" name='actionID' value='exit'>Cancel</button>

when the user clicks OK, I expected to see actionID=set in the request
but instead, I see actionID=OK. Why isn't the value being passed instead of the innerHTML????

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.

wac
12-02-2004, 05:46 PM
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.

wac
12-03-2004, 03:06 PM
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.


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

Command Buttons & Text Field Data Entry?
validating form field if radio button is checked
Question- Please HELP !
how do you create a pop-up window?
window.back() Fails in IE
Querying a page without reloading current page
document.write browser specific response

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics