i'm developing a search engine through travel offers, and i0ve got a couple of fields with start date and end date, with datepicker inside. It works good everywhere but in Internet Explorer 8: it show only the first calendar of the 2...IE gives me an alert in these lines, but i cannot see where is the problem:
function spCalendar( id, options, from, to )
{
jQuery( document ).ready(
function() {
jQuery.extend(
options, {
onClose: function() {
time = jQuery( this ).datepicker( 'getDate' );
jQuery( '#'+this.get( 'id' ).replace( '_selector', '' ) ).val( new Date( time ).valueOf() );
}
}
);
jQuery.extend( options, spCalLang );
jQuery( '#'+id+'_from_selector' ).datepicker( options );
if( from > 0 ) {
jQuery( '#'+id+'_from_selector' ).datepicker( 'setDate', new Date( from ) );
}
else {
jQuery( '#'+id+'_from_selector' ).val( '' );
}
jQuery( '#'+id+'_to_selector' ).datepicker( options );
if( to > 0 ) {
jQuery( '#'+id+'_to_selector' ).datepicker( 'setDate', new Date( to ) );
}
else {
jQuery( '#'+id+'_to_selector' ).val( '' );
}
}
);
}
;
Thanks for help!
try
function() {
jQuery.extend(
options, {
onClose: function(dateText, inst) {
var dtPicker = $("#"+inst.id);
time = dtPicker.datepicker( 'getDate' );
jQuery( jQuery(dtPicker).attr( 'id' ).replace( '_selector', '' ) ).val( new Date( time ).valueOf() );
}
}
);
Also for IE7 Remove the last comma for 'yearSuffix': '',<----
spCalLang = {
'timeOnlyTitle': 'Choose Time',
'timeText': 'Time',
'hourText': 'Hour',
'minuteText': 'Minute',
'secondText': 'Second',
'currentText': 'Oggi',
'closeText': 'Scegli',
'monthNames': ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
'monthNamesShort': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
'dayNames': ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
'dayNamesShort': ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
'dayNamesMin': ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa'],
'weekHeader': '',
'yearSuffix': ''};
I don't know if you're still having this problem, but two problems I saw with your OP code have been fixed below:
function spCalendar(id, options, from, to) {
jQuery(document).ready(function() {
jQuery.extend(options, {
"onClose": function() {
var time = jQuery(this).datepicker('getDate'); //Added var keyword to declare variable
jQuery('#' + this.get('id').replace('_selector', '')).val(new Date(time).valueOf());
}
});
jQuery.extend(options, spCalLang);
jQuery('#' + id + '_from_selector').datepicker(options);
if (from > 0) {
jQuery('#' + id + '_from_selector').datepicker('setDate', new Date(from));
} else {
jQuery('#' + id + '_from_selector').val('');
}
jQuery('#' + id + '_to_selector').datepicker(options);
if (to > 0) {
jQuery('#' + id + '_to_selector').datepicker('setDate', new Date(to));
} else {
jQuery('#' + id + '_to_selector').val('');
}
});
} //removed unnecessary semi-colon
I no longer have IE8, so I am unable to test the site you linked to. Also, the link to http://www.mawitalia.it/viaggidiatlantide/components/com_sobipro/var/js/2b243ae1f1120a3d557ef0e4f3189a89.js returns a 404 - Not Found.