Link to home
Start Free TrialLog in
Avatar of Kristen Jones
Kristen JonesFlag for United States of America

asked on

Javascript broken in Chrome & FF but ok in Explorer

There is a page at http://www.miamiconservancy.org/Water_Data/GWLevels/WellDataDisplay2live.asp?wellname=BUT00013  with JavaScript that has been working for years w/o problems. It was discovered recently that in Chrome or firefox  when you click the View Graph or Download data it does not submit the date range. The date range is computed using JavaScript function CheckDates on the form post

I am hoping for a copy/paste solution to the problem as I don't know JavaScript much




function CheckDates() {

      //alert ("<%=day(mindate)%>");
      //var s,e
      //s=new Date()
      //s.setMonth(SetDate.startm.options(SetDate.startm.selectedIndex).value );
      //s.setYear(SetDate.starty.options(SetDate.starty.selectedIndex).value);
      //s.setDate(SetDate.startd.options(SetDate.startd.selectedIndex).value);

      if (SetDate.startd.options(SetDate.startd.selectedIndex).value > 31) {
            alert ("Invalid date. Please specify again.");
            return false;
      }

      Dates.datestart.value = SetDate.startm.options(SetDate.startm.selectedIndex).value + "/" + SetDate.startd.options(SetDate.startd.selectedIndex).value + "/" + SetDate.starty.options(SetDate.starty.selectedIndex).value;
      GraphDates.datestart.value = SetDate.startm.options(SetDate.startm.selectedIndex).value + "/" + SetDate.startd.options(SetDate.startd.selectedIndex).value + "/" + SetDate.starty.options(SetDate.starty.selectedIndex).value;
      //alert (Dates.datestart.value);

      //e=new Date()
      //e.setMonth(SetDate.endm.options(SetDate.endm.selectedIndex).value );
      //e.setYear(SetDate.endy.options(SetDate.endy.selectedIndex).value);
      //e.setDate(SetDate.endd.options(SetDate.endd.selectedIndex).value);

      if (SetDate.endd.options(SetDate.endd.selectedIndex).value > 31) {
            alert ("Invalid date. Please specify again.");
            return false;
      }

      Dates.dateend.value = SetDate.endm.options(SetDate.endm.selectedIndex).value + "/" + SetDate.endd.options(SetDate.endd.selectedIndex).value + "/" + SetDate.endy.options(SetDate.endy.selectedIndex).value;
      GraphDates.dateend.value = SetDate.endm.options(SetDate.endm.selectedIndex).value + "/" + SetDate.endd.options(SetDate.endd.selectedIndex).value + "/" + SetDate.endy.options(SetDate.endy.selectedIndex).value;
      
      //alert (Dates.dateend.value);
      
      return false;

}


    </script>
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

I have to assume that the "SetDate" variable holds a form with select lists. If so, the parentheses after "options" should be square brackets. Try:
function CheckDates() {

      //alert ("<%=day(mindate)%>");
      //var s,e
      //s=new Date()
      //s.setMonth(SetDate.startm.options[SetDate.startm.selectedIndex].value );
      //s.setYear(SetDate.starty.options[SetDate.starty.selectedIndex].value);
      //s.setDate(SetDate.startd.options[SetDate.startd.selectedIndex].value);

      if (SetDate.startd.options[SetDate.startd.selectedIndex].value > 31) {
            alert ("Invalid date. Please specify again.");
            return false;
      }

      Dates.datestart.value = SetDate.startm.options[SetDate.startm.selectedIndex].value + "/" + SetDate.startd.options[SetDate.startd.selectedIndex].value + "/" + SetDate.starty.options[SetDate.starty.selectedIndex].value;
      GraphDates.datestart.value = SetDate.startm.options[SetDate.startm.selectedIndex].value + "/" + SetDate.startd.options[SetDate.startd.selectedIndex].value + "/" + SetDate.starty.options[SetDate.starty.selectedIndex].value;
      //alert (Dates.datestart.value);

      //e=new Date()
      //e.setMonth(SetDate.endm.options[SetDate.endm.selectedIndex].value );
      //e.setYear(SetDate.endy.options[SetDate.endy.selectedIndex].value);
      //e.setDate(SetDate.endd.options[SetDate.endd.selectedIndex].value);

      if (SetDate.endd.options[SetDate.endd.selectedIndex].value > 31) {
            alert ("Invalid date. Please specify again.");
            return false;
      }

      Dates.dateend.value = SetDate.endm.options[SetDate.endm.selectedIndex].value + "/" + SetDate.endd.options[SetDate.endd.selectedIndex].value + "/" + SetDate.endy.options[SetDate.endy.selectedIndex].value;
      GraphDates.dateend.value = SetDate.endm.options[SetDate.endm.selectedIndex].value + "/" + SetDate.endd.options[SetDate.endd.selectedIndex].value + "/" + SetDate.endy.options[SetDate.endy.selectedIndex].value;
      
      //alert (Dates.dateend.value);
      
      return false;

}

Open in new window

Avatar of Kristen Jones

ASKER

You are correct, you can see the page at the link in the original post and view source.  I tried your code and refreshed using Chrome and still does not submit the date.  I have code at the top right that will display a date if the post is successful .
ASKER CERTIFIED SOLUTION
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:)  that was it.. THANKS!!!!
You're welcome.

For future reference, the correct answer was in my first comment. The second comment which was to correct an error that was introduced while implementing the first correction.