Change value of jquery variable based on a select box
Posted
by Nikos
on Stack Overflow
See other posts from Stack Overflow
or by Nikos
Published on 2010-04-27T00:46:01Z
Indexed on
2010/04/27
0:53 UTC
Read the original article
Hit count: 427
I have a jquery datepicker script and what I want to do is to change "minDate: 10" value by a select box.
$(function() {
$('#hotel').change(function() {
// assign the value to a variable, so you can test to see if it is working
var selectVal = $('#hotel :selected').val();
if( selectVal == "hotel_c" ) {
var date = 10;
}
if( selectVal == "hotel_a" ) {
var date = 15;
}
if( selectVal == "hotel_b" ) {
var date = 6;
}
});
var dates = $('#from, #to').datepicker({
defaultDate: "+1w",
changeMonth: true,
dateFormat: 'yy-m-d',
minDate: 10,
numberOfMonths: 3,
onSelect: function(selectedDate) {
var option = this.id == "from" ? "minDate" : "maxDate";
var instance = $(this).data("datepicker");
var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
dates.not(this).datepicker("option", option, date);
}
});
});
?
© Stack Overflow or respective owner