Skip to content

Instantly share code, notes, and snippets.

@pjmagee
Created May 18, 2012 10:33
Show Gist options
  • Select an option

  • Save pjmagee/2724556 to your computer and use it in GitHub Desktop.

Select an option

Save pjmagee/2724556 to your computer and use it in GitHub Desktop.
$(function () {
$("select#Rooms").val("0");
$("select#room_Children").val("0");
$("select#room_Children_ChildrenAges").val("0");
var rooms = 4;
for (var room = 1; room <= rooms; room++) {
$("div.room#" + room).hide();
$("div.room#" + room).find('select#room_Children_ChildrenAges').closest('div.control-group').hide();
}
$("select#Rooms").change(function () {
for (room = 1; room <= rooms; room++) {
if ($(this).val() >= room) $("div.room#" + room).slideDown('slow');
if ($(this).val() < room) $("div.room#" + room).slideUp('slow');
}
});
$('select#room_Children').change(function () {
var children = 3;
for (var child = 0; child <= children; child++) {
if ($(this).val() > child) {
$(this).closest('div.room')
.find('select#room_Children_ChildrenAges')
.eq(child).parent('div.controls').parent('div.control-group').show();
}
if ($(this).val() <= child) {
$(this).closest('div.room')
.find('select#room_Children_ChildrenAges')
.eq(child).parent('div.controls').parent('div.control-group').hide();
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment