[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

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>
0
Jason Jones
Asked:
Jason Jones
  • 3
  • 2
1 Solution
 
Kim WalkerWeb Programmer/TechnicianCommented:
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

0
 
Jason JonesGIS/APP DevAuthor Commented:
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 .
0
 
Kim WalkerWeb Programmer/TechnicianCommented:
Now you're missing a "</script>" tag which should follow the script above. You should have:
<script type="text/javascript">
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>

Open in new window

0
 
Jason JonesGIS/APP DevAuthor Commented:
:)  that was it.. THANKS!!!!
0
 
Kim WalkerWeb Programmer/TechnicianCommented:
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.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now