javascript - How to make this work in all other browsers other than Firefox -
I have a list with a number in it, this number goes from 0 to 30. I want to hide the numbers based on the current date and the number of days other than the user set
So if today is 28 July 2010 and they have set July 29, 2010 it should only be shown "0"
If it was 28 July 2010 and they were on September 20, 2010 , It should show 0 to 30.
Then I have it
var selectedDate = new date ($ ('# text box'). Val (). Replace (/ \ / (\ d \ d ) $ /, "/ 20 $ 1")); Var currentDate = new date (); Var month = currentDate.getMonth () + 1 var day = currentDate.getDate () var year = currentDate.getFullYear () currentDate = new date (month + "/" + day + "/" + year); If (isNaN (selectedDate) == false) {$ ('# selectList') Find ('Select'). Attr ('disabled', ''); Var diffDays = parseInt ((selected date - current date) / (1000 * 60 * 60 * 24)); Var option = $ ('# selectList'). Find ('option'); JQuery.each (option, function (i, value) {var currentvol = $ (this) .val (); if (current value == -1) {// equal to continue; return true;} and if (current Value> = DiffDays) {$ (this) .hide ();} and {$ (this) .show ();}}); }
This code is on the change of the text box where the user can select a date.
It works fine in Firefox but does not work in any other browser. I do not know why no browser is visible in the browser.
You can not just hide / & lt; Options & gt;
For this cross-browser such elements, you have to backup / hide & lt; Select & gt;
and only & lt; Options & gt;
the element that you want every time, or just & lt; Options & gt; You do not want to disable the
elements, but it will appear to them.
The cloning bit is something like this:
var hiddenSelect = $ ("# selectList"). ('Select') to find. Clone (); Var selectedDate = new date ($ ('# textbox'). Val (). Replace (/ \ / (\ d \ d) $ /, "/ 20 $ 1")); Var currentDate = new date (); Var month = currentDate.getMonth () + 1 var day = currentDate.getDate () var year = currentDate.getFullYear () currentDate = new date (month + "/" + day + "/" + year); If (isNaN (selectedDate) == false) {$ ('# selectList') Find ('Select'). Attr ('disabled', ''); Var diffDays = parseInt ((selected date - current date) / (1000 * 60 * 60 * 24)); Choose Var = $ ('# selectList'). ('Select'). Blank (); Hidden Choice Children () Each (function (i, value) {if (value == -1) {return true;} and if (current value
We only copy a clone in the original, which we put in a variable named hidden selection
, the options visible in the UI are blank )
Comments
Post a Comment