<td class="row" id="253">
<select class="available-room" style="" id="roomToBook">
<option value="0">Select</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>
<option value=10>10</option>
</select>`enter code here`
</td>
<td class="row" id="253">
<select class="available-room" style="" id="roomToBook">
<option value="0">Select</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>
<option value=10>10</option>
</select> </td>
<td class="row" id="253">
<select class="available-room" style="" id="roomToBook">
<option value="0">Select</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>
<option value=10>10</option>
</select> </td>
I have a three table cell having different id. Here i want to get the id when user select the option of respective id and add id in a array when user select the two or more then two option value from different table cell in a same time. I have a javascript code also.It shows same id in alert frequently in every selection of option value of same id.Please someone help me.
$(document).ready(function() {
$(document).on('change', '.available-room', function () {
var room_id = new Array();
room_id.push($(this).parent('td').attr('id'));
alert(room_id);
});
});
idattributes must be unique in the document, you can't use the sameidon more than one element. So that's the first thing to fix. If you need to group elements together,classis useful. (You'll also get people telling youids can't be numeric. They can, but if you need to use CSS selectors with numericidvalues, it's a pain. [The only restrictions are they must be unique, can't contain spaces, and must have at least one character if given.])