Solved

Javascript broken in Chrome & FF but ok in Explorer

Posted on 2012-04-04
5
415 Views
Last Modified: 2012-04-04
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
Comment
Question by:upgraders
  • 3
  • 2
5 Comments
 
LVL 21

Expert Comment

by:Kim Walker
ID: 37805657
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
 
LVL 1

Author Comment

by:upgraders
ID: 37805802
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
 
LVL 21

Accepted Solution

by:
Kim Walker earned 500 total points
ID: 37805878
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
 
LVL 1

Author Comment

by:upgraders
ID: 37805922
:)  that was it.. THANKS!!!!
0
 
LVL 21

Expert Comment

by:Kim Walker
ID: 37805943
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now