select value of 2 html select element witht the jquery

I have a situation where i have to select the dropdown value like this

$(this).parent().parent('div').find('option:selected').val();

later i realized that i need to put 2nd ddl there in the same div, so now i become confuse how to fetch the value of each of this DDL. is there a way to apply id for this code

$(this).parent().parent('div').find('option:selected').val();

so that i can fetch each.

following is my code this is first ddl.

<select style="width:30px" name="ddlQty" id="ddlQty" class="positive-integer"><option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>

and this is second

<select name="OptionID" id="OptionID"><option value="14">5''  £25.00</option>
</select>

how can i select each of this value?

Answers


For the fisrt one:

$(this).parent().parent('div').find('#ddlQty option:selected').val();

And the second one:

$(this).parent().parent('div').find('#OptionID option:selected').val();

If Id's are unique as it should

$('#ddlQty').val();

and

$('#OptionID').val();

$('#ddlQty').val();
$('#OptionID').val();

would get the value of each select menu.


IDs should be unique, so you shouldn't need the $(this).parent().parent('div') part. The following should work

$('#ddlQty').val();
$('#OptionID').val();

Need Your Help

Paste Value all the cells in a given sheet if Cell has Vlookup formula..

loops excel-vba excel-2007

=VLOOKUP(VALUE($B$100);INDIRECT("2011.xls!"&amp;D$101;0);3;0)

Using piped streams and jaxb

jaxb marshalling inputstream outputstream

I cannot figure out whether I am using piped streams improperly or whether my problem is elsewhere in the issue below.