<td>
<form id="selectValue">
<select class="priorityList" name="priorityList1">
<option value="">Select Priority</option>
<option value="1">Low</option>
<option value="2">Medium</option>
<option value="3">High</option>
</select>
</form>
</td>
<td>
<form id="selectValue">
<select class="priorityList" name="priorityList2">
<option value="">Select Priority</option>
<option value="1">Low</option>
<option value="2">Medium</option>
<option value="3">High</option>
</select>
</form>
</td>
JS
$('select[name=priorityList1]').val()//in some cases, returns null
$('#priorityList1').val()//method 2 this returns null some times
$('#priorityList1 option:selected').val()//this works everytime
//for second priority list
$('select[name=priorityList2]').val()//in some cases, returns null
$('#priorityList2').val()//method 2 this returns null some times
$('#priorityList2 option:selected').val()//this works everytime
//to change names and Id through Jquery
$("#" + id).attr('id', 'priority' + counterIndex)
.attr('name', 'prioty' + counterIndex);
Apparently you tried the above and it is not working.
- Make sure you are having only one select named priorityList
Make sure your ids are unique
Only two, three, four or more radio buttons can have the same name, the rest can't: explanation
- If you are auto-generating this form, let's say if the user enters a new row and you need to auto generate the id, you can keep count of the user's entry and change the name/id using a Js function you will have to write this by yourself. Here is an example