scripter73
Programmer
Hi,
I am submitting a form via a link. The form accepts a date range, and depending on which link the user selects, I want to change the action attribute of my form.
My present code doesn't redirect to the page. If I hard-code the action field to something like: <form action="pageb.cfm">, it redirects/passes value fine.
Please consider my two files: pagea.cfm and pageb.cfm:
PAGEA.CFM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Page A</title>
<script language="javascript">
function sendform(report_type){
document.form1.submit();
if (report_type == 1)
window.location.href="pageb.cfm";
else if (report_type == 2)
window.location.href="pagec.cfm";
}
</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="form1" action="" method="post">
<input type="text" name="month" size=3 maxlength=2>
<input type="text" name="day" size=3 maxlength=2>
<input type="text" name="year" size=5 maxlength=4>
</form>
<a href="javascript:sendform(1);" name="Link1">Report Link 1</a>
<a href="javascript:sendform(2);" name="Link2">Report Link 2</a>
</body>
</html>
PAGEB.CFM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<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="text" name="bmonth" value="<cfoutput>#session.aMonth#</cfoutput>" size=3 maxlength=2>
<input type="text" name="bday" value="<cfoutput>#session.aDay#</cfoutput>" size=3 maxlength=2>
<input type="text" name="byear" value="<cfoutput>#session.aYear#</cfoutput>"size=5 maxlength=4><br>
<input type="button" name="newrpt_sweep" value="Submit New Date">
</body>
</html>
If you'd like to take a look at this in action, please goto.
You can click on Report1 link, and Report2 link. It's not passing my values.
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.
Any help you can provide is appreciated.
Thanks,
scripter73
I am submitting a form via a link. The form accepts a date range, and depending on which link the user selects, I want to change the action attribute of my form.
My present code doesn't redirect to the page. If I hard-code the action field to something like: <form action="pageb.cfm">, it redirects/passes value fine.
Please consider my two files: pagea.cfm and pageb.cfm:
PAGEA.CFM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Page A</title>
<script language="javascript">
function sendform(report_type){
document.form1.submit();
if (report_type == 1)
window.location.href="pageb.cfm";
else if (report_type == 2)
window.location.href="pagec.cfm";
}
</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="form1" action="" method="post">
<input type="text" name="month" size=3 maxlength=2>
<input type="text" name="day" size=3 maxlength=2>
<input type="text" name="year" size=5 maxlength=4>
</form>
<a href="javascript:sendform(1);" name="Link1">Report Link 1</a>
<a href="javascript:sendform(2);" name="Link2">Report Link 2</a>
</body>
</html>
PAGEB.CFM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<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="text" name="bmonth" value="<cfoutput>#session.aMonth#</cfoutput>" size=3 maxlength=2>
<input type="text" name="bday" value="<cfoutput>#session.aDay#</cfoutput>" size=3 maxlength=2>
<input type="text" name="byear" value="<cfoutput>#session.aYear#</cfoutput>"size=5 maxlength=4><br>
<input type="button" name="newrpt_sweep" value="Submit New Date">
</body>
</html>
If you'd like to take a look at this in action, please goto.
You can click on Report1 link, and Report2 link. It's not passing my values.
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.
Any help you can provide is appreciated.
Thanks,
scripter73