Created
August 14, 2011 14:30
-
-
Save thanashyam/1144920 to your computer and use it in GitHub Desktop.
Updating values of "Age from" and "Age To" select inputs based values from the other
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#agefrom').live('change',function() { | |
var age_from = parseInt($('#agefrom').val()); | |
var age_to = parseInt($('#ageto').val()); | |
if (age_to < age_from) { | |
$('#ageto option:selected').removeAttr('selected'); | |
if (age_from < 99) { | |
$('#ageto option[value="'+ String(age_from + 1) + '"]').attr('selected','selected'); | |
} else { | |
$('#ageto option[value="99"]').attr('selected','selected'); | |
} | |
$.uniform.update("#ageto"); // For UniformJs | |
} | |
}); | |
$('#ageto').live('change',function() { | |
var age_from = parseInt($('#agefrom').val()); | |
var age_to = parseInt($('#ageto').val()); | |
if (age_to < age_from) { | |
$('#agefrom option:selected').removeAttr('selected'); | |
if (age_from < 99) { | |
$('#agefrom option[value="'+ String(age_to - 1) + '"]').attr('selected','selected'); | |
} else { | |
$('#agefrom option[value="18"]').attr('selected','selected'); | |
} | |
$.uniform.update("#agefrom"); // For UniformJs | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment