views:

35

answers:

3

I have a set of radio buttons that is in between other controls that are part of an HTML form. I do not want the value of these radio buttons to be submitted with the query (I am just using these radio buttons for JavaScript stuff). Normally, I can do this with other controls (i.e. checkboxes, etc.) by not having a "name" attribute for them, and they won't get submitted. However, the "name" attribute is required in order for radio buttons to have their "mutually-exclusive" behavior. I cannot move the radio buttons outside of the form either, because it's situated in between other controls that do need to be submitted with the form. Also, I cannot disable the radio buttons because I need the user to be able to click them. So is there a way I can make a set of radio buttons that do not get submitted with the form?

+2  A: 

I can think of a couple solutions:

Elements in an <iframe />

One would be to place the buttons within an iframe, within your form, and merely turn the border of the iframe off so as to give the impression they are in the form.

Remove during "Submit"

Another solution would be to remove the element from the form via Javascript on the forms submit action, sending a truncated list of elements back to the server.

If it were me, I'd just ignore the elements on the server-side.

Jonathan Sampson
A: 

You have a few options on this one.

bpeterson76
A: 

If you didn't care about validity, you could still have the radio buttons, and not give them names. Your JS can identify them by their IDs, and without names, they won't pass any parameters.

McTrafik