?
Solved

Javascript broken in Chrome & FF but ok in Explorer

Posted on 2012-04-04
5
Medium Priority
?
423 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:Jason Jones
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Jason Jones
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 2000 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:Jason Jones
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

777 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