View Full Version : Processing select/option with optiongroup

04-22-2012, 03:52 AM
I know this is not a forum for html, but I am developing a script that processes form post vars that contain select/option elements with optgroup tag sets.
Do browsers sent this value, or any indication with the selected value(s)?
If so, how and what should be looked for by processing script?

Could I add a name attribute to the optgroup opening tag?
(texts I have to hand do not say anything about this)

Thanks for time and attention

04-22-2012, 04:06 AM
optgroups cannot be selected - they are simply a way of grouping the options.

Only the select itself can have a name and the options supply the values.

If you want to identify which optgroup the option was in then you will need to set the option values so they identify the group as well as the individual option.

04-22-2012, 04:45 AM
These suggestions will work. But it seems to me, though I do not remember specifically how or where, I did a select/option element with nested select/options
Am I dreaming, or is this possible? I can solve the problem easily with javascript but I am writing code to avoid javascript in the spirit of 'unobtrusive javascript'. Once everything will work without it, I will start adding it.

04-24-2012, 05:13 AM
That's the idea.

04-24-2012, 10:55 AM
There is jquery plugins to emulate that type of behaviour, but if I were to create a simple one I'd just create the categories with the html:

<option value = "">--Category</option>


<option value = "">&nbsp;&nbsp;&nbsp;--Sub Category</option>

It's not perfect but it's quick, easy and gives the same illusion as optgroups that are selectable.