I would like to create another select box from a select box value. through Jquery.
We have applied this codes and it’s not working at the moment.
<script src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script>
$(document).ready(function () {
var rooms = $("#rooms");
var ROOMS = rooms.val() ;
var max_adults_a = 3;
var min_adults_a = 2;
var max_adults = max_adults_a;
var min_adults = min_adults_a;
var num = min_adults * ROOMS;
ROOMS.change(function() {
while (num <= max_adults_a * ROOMS) {
$('#person').append($('<option></option>').val(num).html(num)
)};
});
});
</script>
</head>
<body>
<h1>Populating Select Boxes</h1>
Category:
<select name="rooms" id="rooms">
<option Selected value="">Select</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
person
<select name="person" id="person">
</select>
</body>
we have 2 select box one for rooms, and other for Persons, We have a list for Rooms, but we have to update the Persons according to the rooms size, if we have a room type “3” then the persons will be allowed for this room is 6,7,8,9.
The options for Persons will change accordingly.
Please provide me suitable solutions
Thanks
Rod
1 Answer