Rizstien
Rizstien

Reputation: 802

How to check from which optgroup an option is picked from <select> html feild

i am using struts tag with . there are two opt groups with same keys but different values. when i submit my form, keys go to server to save. now on server side i want to check with which optgroup it was associated how can i do it ? following is html code

<optgroup label="Group1">
<option value="1">opt1</option>
<option value="3">opt2</option>
<option value="4">opt3</option>
</optgroup>
<optgroup label="Group2">
<option value="1">opt4</option>
<option value="3">opt5</option>
<option value="4">opt6</option>
</optgroup>

Upvotes: 2

Views: 601

Answers (1)

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114417

Use different values, such as:

<option value="grp1_1">opt1</option>

...

<option value="grp2_1">opt1</option>

Then parse out the value on the server after the for is submitted.

Upvotes: 3

Related Questions