Thank you in advance for any help you can provide.
I have a form with a date picker on it, so if you click on the input box a nice looking calendar pops up. Clicking on a specific day in the calendar, then fills in the date on the input box.
Next I have an input box for selecting a time. Based on the day of the week, the list of times change. For example, if you pick a Friday, only 10am - 1pm options will show.
I have this working in firefox only. On IE and Safari, if you pick a friday, it will show 9am - 6pm, which is the default. It looks like the hide() is not working.
I'm not seeing any error messages in developer tools for IE or safari.
Here is the HTML:
<input alt="date" type="text" name="formfield_day" id="formfield_day" />
<select name="formfield_time" id="formfield_time" class="ri_field">
<option value="0" selected="selected">Time</option>
<option value="9 am" id="time9">9:00 AM</option>
<option value="10 am" id="time10">10:00 AM</option>
<option value="11 am" id="time11">11:00 AM</option>
<option value="12 pm" id="time12">12:00 PM</option>
<option value="1 pm" id="time1">1:00 PM</option>
<option value="2 pm" id="time2">2:00 PM</option>
<option value="3 pm" id="time3">3:00 PM</option>
<option value="4 pm" id="time4">4:00 PM</option>
<option value="5 pm" id="time5">5:00 PM</option>
<option value="6 pm" id="time6">6:00 PM</option>
</select>
Here is the javascript:
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script>
$(document).ready(function(){
$("#formfield_day").datepicker({
beforeShowDay: nonWorkingDates,
minDate: 0,
maxDate: "+2m"
});
});
</script>
<script>
$( document ).ready(function() {
changeTime();
});
$('#formfield_day').bind('change', function(event) {
changeTime();
});
function changeTime() {
// var x = $('#formfield_day').val();
var currentDate = $( "#formfield_day" ).datepicker( "getDate" );
var weekday = new Array(7);
weekday[0]= "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
if (currentDate) {
var dayName = weekday[currentDate.getDay()];
hideAll();
if (dayName == "Tuesday") {
hideAll();
$('#time1').show();
$('#time2').show();
$('#time3').show();
$('#time4').show();
$('#time5').show();
$('#time6').show();
}
else if (dayName == "Friday") {
hideAll();
$('#time9').show();
$('#time10').show();
$('#time11').show();
$('#time12').show();
}
}}
function hideAll() {
$('#time1').hide();
$('#time2').hide();
$('#time3').hide();
$('#time4').hide();
$('#time5').hide();
$('#time6').hide();
$('#time7').hide();
$('#time8').hide();
$('#time9').hide();
$('#time10').hide();
$('#time11').hide();
$('#time12').hide();
}
</script>
Any ideas? I'd appreciate any help with tracking down this bug.