472,143 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

From Date/To Date Issue

Stang02GT
1,208 Expert 1GB
Here is the issue that I am having. I have two text feilds where users need to enter a "From Date:" and a "To Date:" they then hit a update button and my code will pull back the data for the date ranges they have selected.

If the user enters the same date in both from and to fields they are expecting to see just one row returned for that day, BUT what is really happening is it is returning all the data.

Does anyone have any suggestions or ideas on how I can just have one row return if the users enter the same date?


Expand|Select|Wrap|Line Numbers
  1. <SCRIPT language="javascript">
  2.  
  3. function submit() {
  4.  
  5.     var fundshareid = document.getElementById('fundshareid').value;
  6.     var fd = document.getElementById('fd').value;
  7.     var td = document.getElementById('td').value;
  8.  
  9.     var tp = "<%=request.getParameter("tp")%>";
  10.  
  11.     if (tp == null || tp == "null") {tp = "fl";}
  12.  
  13.     return document.location = "<%=request.getAttribute("baseURI")%>" + "?fd=" + fd + "&fundshareid=" + fundshareid + "&link=products&td=" + td + "&tp=" + tp + "&ut=" + "<%=request.getParameter("ut")%>";
  14.  
  15. }
  16.  
  17. function validate(){
  18.  
  19.     if (isDate(document.forms[1].fd.value)==false){
  20.         document.forms[1].fd.focus();
  21.         return false;
  22.     }
  23.     if (isDate(document.forms[1].td.value)==false){
  24.         document.forms[1].td.focus();
  25.         return false;
  26.     } else {
  27.         fd = new Date(document.forms[1].fd.value);
  28.         td = new Date(document.forms[1].td.value);
  29.         if (fd > td){
  30.             alert("We're sorry, but we are unable to display the requested data.  Please select a \"To Date\" that is greater (more recent) than the \"From Date.\"");
  31.             return false;
  32.         }
  33.     }
  34.  
  35. return true;
  36. }
Aug 7 '08 #1
1 1454
acoder
16,027 Expert Mod 8TB
You don't need a submit() function to do this job for you when you can just let the browser pass the values in the correct format. If you use this format:
Expand|Select|Wrap|Line Numbers
  1. <form ... onsubmit="return validate()">
then the form will submit if validate() returns true. If you need extra values, add some hidden values.
Aug 7 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by |-|erc | last post: by
2 posts views Thread by sandy | last post: by
12 posts views Thread by HarveyB | last post: by
4 posts views Thread by SQLJunkie | last post: by
21 posts views Thread by Darin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.