tags:

views:

49

answers:

1

If for some reason it were mandatory to associate a <button> with more than one value, is there a good way to do it? For example ...

CSV: 
  <button value="Lancelot,Grail,blue">Answer</button>
JSON: 
  <button value="{'name':'Lancelot','quest':'Grail','color':'blue'}">Answer</button>

In the absence of a good way to do it, is there a traditional way?

Edit: another use case

Server M, the producer of the HTML, knows the user's current location and favorite genres, movie names, nearest theater, and next showtime. Server F knows how to query various 3rd party servers about how to get from point A to point B in order to arrive by time T. The user knows only the movie names: click Drag Me to Hell, and get the route. Server M could generate a form for each movie, with a single button showing the name of the movie and multiple hidden fields with the start and end locations and desired arrive-by time, but that would require a lot of repeated code. Every one of these one-button mini-forms would have the same method and action and the same hidden input field structure. Styling would be a collection of mini-forms rather than a collection of buttons, so FIELDSET and LEGEND are unavailable (because HTML forbids nested forms). Putting the parameters into the button's value attribute would be much tidier.

+1  A: 

Well if you have to have a button element, why not use JavaScript to set a bogus property:

$('mybutton').compoundValue = { ... json ... };

and then reading the 'compoundValue's during form submit, etc.

Though really you might want to consider a group of checkboxes or some other form bits for what you're trying to accomplish.

Eric Wendelin
Alas, if the client has disabled JavaScript, the degradation is fairly graceless. +1 for the suggestion, though.
Thomas L Holaday
For complete graceful degradation, you'll have to go with separate form elements or forcing your server-side to parse comma-separated values. Also, it is now quite rare for people to disable JavaScript and certainly not unheard of for webapps to require it.
Eric Wendelin
@Eric Wendelin, count your blessings. A significant fraction of the enduser-population of one of my clients is using the AOL browser.
Thomas L Holaday