Solved

Javascript broken in Chrome & FF but ok in Explorer

Posted on 2012-04-04
5
417 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 22

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 22

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 22

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

939 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

6 Experts available now in Live!

Get 1:1 Help Now