Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get the value of the dropdown of the particular row in a table using jquery

here is my html code

<td style="display:none">
    <div class="col-sm-6">
        <select class="form-control" id="riexclusion">
            <option value="yes">Yes</option>
            <option value="no">No</option>
        </select>
    </div>
</td>

i want to get the selected value from the dropdown list of every row.

I tried this jquery to retrieve the value..

var selectedstatus = $('#riexclusion option:selected').text();
alert(selectedstatus);
var totalrow = $("#ritable > tbody > tr").length;
for (var i = 0; i <= totalrow; i++) {
    exclusion = $('tbody#riDecisionvalues tr:eq(' + i + ')td:eq(8)').select();
}

help me with this...

add jsfiddle

like image 946
Aarthi Ravendiran Avatar asked Jan 21 '26 13:01

Aarthi Ravendiran


1 Answers

First of all you need to remove duplicate ids instead you can use class as shown below -

<td style="display:none">
    <div class="col-sm-6">
        <select class="form-control" class="riexclusion">
            <option value="yes">Yes</option>
            <option value="no">No</option>
        </select>
    </div>
</td>

Use below jQuery to get each selected value from dropdown

//iterate all select under each tr
$("#ritable  tbody  tr").find(".riexclusion").each(function(){
   selectedVal = $(this).val();
   alert(selectedVal);
});
like image 106
Bhushan Kawadkar Avatar answered Jan 24 '26 02:01

Bhushan Kawadkar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!