KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
We are using jQuery .hide() to hide options in select inputs - when there are less than 31 days in a month. It works fine with Google Chrome and FireFox, but it doesn't work in Internet Explorer, Opera and Safari. Here is the JavaScript code we are using: $(function() { // Show and hide days according to the selected year and month. function show_and_hide_days(fp_form) { var select_year= $(fp_form).find("select.value_year"); var select_month= $(fp_form).find("select.value_month"); var select_day= $(fp_form).find("select.value_day"); var selected_year= parseInt($(select_year).val()); var selected_month= parseInt($(select_month).val()); var selected_day= parseInt($(select_day).val()); var days_in_month= new Date(selected_year, selected_month, 0).getDate(); if ((days_in_month >= 28)) { // If selected day is bigger than the number of days in the selected month, reduce it to the maximal day in this month. if (selected_day > days_in_month) { $(select_day).val(days_in_month); } // Show all the days in this month and hide days which are not in this month. $(select_day).find("option").each(function() { var day= parseInt($(this).val()); if (day <= days_in_month) { $(this).show(); } else { $(this).hide(); } }); } } // Show and hide all days in this page. function show_and_hide_all_days() { $("select.value_day").each(function() { var form= $(this).closest("form"); // Show and hide days according to the selected year and month. show_and_hide_days(form); }); } // Show and hide all days in this page. show_and_hide_all_days(); $("select.va
Tags (comma-separated)
Save Edits
Cancel