Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Date Range Form With Links

Status
Not open for further replies.

scripter73

Programmer
Joined
Apr 18, 2001
Messages
421
Location
US
Hi,

It seemed easy at the time, but as usual I'm making it complicated.

I have a web page A where the idea is to allow a user to select a date range, and then click on a report name (that goes to web page B) that presents some data based on the range selected. I also need the date range on my "B" page.

I'm utilizing a small form for the date, and links for the report names. The issue is that I'm not using the traditional "Submit" button. From a user perspective, I don't need it.

You can check out the site for yourself to see what I mean.

Click on: (for Web Page A), and then click on "Sweep Bank Reconciliation" link (for Web Page B).

I'd like to keep my design (where I represents links for the reports). Things like checkboxes and select boxes wouldn't provide the look I want.

It seems like it would be easy, but its more difficult than I anticipated.

Should I use a Javascript function to pass the values? (I'm also using hidden fields).

Sorry this is so long, but here's a copy of my code for PAGE A:


<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<html>
<head>
<title>Agency Reports - Homepage</title>
<script language=&quot;Javascript&quot;>
<!--
function process_date(){
//grab the form's dates


}

-->
</script>

<link rel=&quot;stylesheet&quot; type&quot;text/css&quot; href=&quot;style.css&quot;>
</head>

<body>
<cfset session.sysdate = DateFormat(Now(),&quot;yyyymmdd&quot;)>
<cfset session.dateYear = Mid(session.sysdate,1,4)>
<cfset session.dateMonth = Mid(session.sysdate,5,2)>
<cfset session.dateDay = Mid(session.sysdate,7,2)>
<!--- 1/21/01 Get agent code. --->
<cfset session.agentcode = &quot;AXXXX&quot;>



<TABLE WIDTH=800 CELLSPACING=0 CELLPADDING=0 BORDER=0>
<!--- Row 2--->
<tr border=1>
<td width=420 height=20 valign=&quot;middle&quot;><b><p>Please enter a date range and click on the report you would like to view.</b></p></td>
<td width=380 height=20></td>
</tr>
<!--- Row 3--->
<form name=&quot;homedate&quot; action=&quot;sweep_cr.cfm&quot; method=&quot;post&quot;>
<tr border=1>
<td width=420 height=20 valign=&quot;bottom&quot;><input type=&quot;text&quot; size=3 maxlength=2 name=&quot;startmonth&quot; value=&quot;<cfoutput>#session.dateMonth#</cfoutput>&quot;>/<input type=&quot;text&quot; size=3 maxlength=2 name=&quot;startday&quot; value=&quot;<cfoutput>#session.dateDay#</cfoutput>&quot;>/<input type=&quot;text&quot; size=5 maxlength=4 name=&quot;startyear&quot; value=&quot;<cfoutput>#session.dateYear#</cfoutput>&quot;>
<b>TO</b> <input type=&quot;text&quot; size=3 maxlength=2 name=&quot;endmonth&quot; value=&quot;<cfoutput>#session.dateMonth#</cfoutput>&quot;>/<input type=&quot;text&quot; size=3 maxlength=2 name=&quot;endday&quot; value=&quot;<cfoutput>#session.dateDay#</cfoutput>&quot;>/<input type=&quot;text&quot; size=5 maxlength=4 name=&quot;endyear&quot; value=&quot;<cfoutput>#session.dateYear#</cfoutput>&quot;><!---1/23/02 Don't need a submit button right now.    <img src=&quot;images/submit.gif&quot; name=&quot;submit&quot; onclick=&quot;&quot;> ---><!--- <input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;> ---></td>
<td width=380 height=20></td>
<!--- End of cell containing date range.--->
</tr>
<input type=&quot;hidden&quot; name=&quot;month1&quot; value=&quot;&quot;>
<input type=&quot;hidden&quot; name=&quot;day1&quot; value=&quot;&quot;>
<input type=&quot;hidden&quot; name=&quot;year1&quot; value=&quot;&quot;>
<input type=&quot;hidden&quot; name=&quot;month2&quot; value=&quot;&quot;>
<input type=&quot;hidden&quot; name=&quot;day2&quot; value=&quot;&quot;>
<input type=&quot;hidden&quot; name=&quot;year2&quot; value=&quot;&quot;>

</form>
<!--- Row 4 --->
<tr colspan=3>
<td width=420 height=20>
<table width=420 border=0 cellpadding=0 cellspacing=0>
<tr valign=&quot;top&quot;>
<td width=150 valign=&quot;top&quot;>
<table width=150 border=0 cellpadding=0 cellspacing=0>
<tr width=150>
<td width=30 align=&quot;left&quot; valign=&quot;top&quot;><font size=-3>MM</font></td>
<td width=30 align=&quot;center&quot; valign=&quot;top&quot;><font size=-3>DD</font></td>
<td width=50 align=&quot;center&quot; valign=&quot;top&quot;><font size=-3>   YYYY</font></td>
</tr>
</table>
</td>
<td width=5></td>
<td width=150 valign=&quot;top&quot;>
<table width=150 border=0 cellpadding=0 cellspacing=0>
<tr width=150>
<td width=30 align=&quot;left&quot; valign=&quot;top&quot;><font size=-3>  MM</font></td>
<td width=30 align=&quot;center&quot; valign=&quot;top&quot;><font size=-3>   DD</font></td>
<td width=50 align=&quot;right&quot; valign=&quot;top&quot;><font size=-3>   YYYY</font></td>
</tr>
</table>
</td>
<td width=170></td>
</tr>
</table>
</td>

<td width=380 height=20></td>
</tr>
<tr border=1>
<td width=420></td>
<td width=380 align=&quot;center&quot;></td>
</tr>
<!--- Row 5--->
<tr border=1>
<td width=800 colspan=2><hr size=&quot;3&quot;color=&quot;black&quot;></td>
</tr>
<!--- Row 6--->
<tr border=1>
<td width=400 height=30 align=&quot;right&quot; bgcolor=&quot;#660000&quot;><font color=&quot;white&quot; size=3>Agency Reports |</font></td>
<td width=400 height=30 align=&quot;left&quot; bgcolor=&quot;#660000&quot;><font color=&quot;white&quot; size=3>Agent Code   <cfoutput>#session.agentcode#</cfoutput></font></td>
</tr>
<!--- Row 7--->
<tr border=1>
<td width=800 colspan=2><hr size=&quot;3&quot;color=&quot;black&quot;></td>
</tr>
<!--- Row 8--->
<tr border=1>
<td width=400 valign=top>
<!--- Start of Homepage Links(Left)--->
<table width=380 border=2 bordercolor=&quot;#000000&quot; cellspacing=5 cellpadding=5 bgcolor=&quot;#FFFFFF&quot;>
<!--- Link 1 --->
<tr><td height=85 valign=top>Sweep Bank Information <br clear=right>     <a href=&quot;sweep_cr.cfm&quot; onclick=&quot;process_date()&quot;><b>Sweep Bank Reconciliation</b></a></td></tr>
..... More Links Here .....


<!--- End of Homepage Links (Right)--->
</td>
</tr>
</TABLE>
</body>
</html>


Thanks in advance for any help you can provide.

scripter73
 
DO you want each one of the links on page a to pass the date information to a different page, or just &quot;Sweep Bank Reconciliation&quot;? - tleish
 
Hi Tleish,

Different pages. Each link clicked on goes to another page. I got as far as creating the links to the pages.

Below I have a link to a scaled down version of what I'm trying to accomplish:


Please consider my two files: pagea.cfm and pageb.cfm:

PAGEA.CFM

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<html>
<head>
<title>Page A</title>

<script language=&quot;javascript&quot;>
function sendform(report_type){
document.form1.submit();


if (report_type == 1)
window.location.href=&quot;pageb.cfm&quot;;

else if (report_type == 2)
window.location.href=&quot;pagec.cfm&quot;;

}

</script>
</head>

<body>
SUBMITTING A FORM VIA A LINK: This form takes a value from the user and lets the user choose which report they would like to view. (The date values are posted to the next page.)<br>


<form name=&quot;form1&quot; action=&quot;&quot; method=&quot;post&quot;>
<input type=&quot;text&quot; name=&quot;month&quot; size=3 maxlength=2>
<input type=&quot;text&quot; name=&quot;day&quot; size=3 maxlength=2>
<input type=&quot;text&quot; name=&quot;year&quot; size=5 maxlength=4>
</form>

<a href=&quot;javascript:sendform(1);&quot; name=&quot;Link1&quot;>Report Link 1</a>

<a href=&quot;javascript:sendform(2);&quot; name=&quot;Link2&quot;>Report Link 2</a>

</body>
</html>




PAGEB.CFM


<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<html>
<head>
<title>Page B</title>
</head>

<body>
<cfset session.aMonth = #form.month#>
<cfset session.aDay = #form.day#>
<cfset session.aYear = #form.year#>

The values you selected from the previous form.
<input type=&quot;text&quot; name=&quot;bmonth&quot; value=&quot;<cfoutput>#session.aMonth#</cfoutput>&quot; size=3 maxlength=2>
<input type=&quot;text&quot; name=&quot;bday&quot; value=&quot;<cfoutput>#session.aDay#</cfoutput>&quot; size=3 maxlength=2>
<input type=&quot;text&quot; name=&quot;byear&quot; value=&quot;<cfoutput>#session.aYear#</cfoutput>&quot;size=5 maxlength=4><br>
<input type=&quot;button&quot; name=&quot;newrpt_sweep&quot; value=&quot;Submit New Date&quot;>

</body>
</html>


The reason these files are .cfm files is because I'm using the date field in the next page. But my question is HTML/Javascript-related.

I think there's something I need to do in the Javascript, but I'm not sure what. It seems like I'm almost there, but not quite.

Any help you can provide is appreciated.

Thanks,
scripter73
 
Ah, I see what you're after. Obviously, you could pass the two dates as parameters on the end of the link's URL. However, you have to write those URLs before the user has selected the two dates.

You're correct that you need to use Javascript. I see that you have created empty hidden fields to hold the date parts. You apparently intended to assign values to those fields with Javascript. However, you need to get those values appended to the links' URLs for this to work. You don't need these hidden form fields, since if you can assign values to them, you could have just as well appended the values to the URLs.

Here is an example taken from your page that shows how I would approach this:

Make your links like this:

<a href=&quot;javascript: getDocsInRange('meeka1/sweep_cr.cfm');&quot;>Sweep Bank Reconcilliation</a>

And at the top of your page, insert this Javascript:

<script language=&quot;javascript&quot;>
function getDocsInRange(url_suffix) {
var f = document.homedate; // this is your form

var startdate = f.startmonth.value + '/' + f.startday.value + '/' + f.startyear.value;
var endate = f.endmonth.value + '/' + f.endday.value + '/' + f.endyear.value;

window.location=' + url_suffix + '?startdate=' startdate + '&enddate=' + enddate;
}
</script>

Then, in your template sweep_cr.cfm, you can use the CF variables URL.startdate and URL.enddate in your query like this:

SELECT ...
...
WHERE date between #CreateODBCDate(startdate)# and #CreateODBCDate(enddate)#

Let me know if this works. I haven't tested it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top