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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Landing ("Action") Page

Status
Not open for further replies.

scripter73

Programmer
Apr 18, 2001
421
US
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=&quot;pageb.cfm&quot;>, it redirects/passes value fine.

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>


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
 
you could have logic at the top of pagea.cfm or pageb.cfm that will redirect depending on what was entered in the form.

could even have the form submit back to itself

<form action=&quot;thispage.cfm&quot;>

and have the logic at the top of the form page to redirect based on form input.
 
Thanks for your response lobstah.

I'm not sure if I follow, though.

Are you talking about something like this:

pagea.cfm

.....
<body onsubmit=&quot;(this)&quot;>

.....

Is this even valid?

Thanks in advance for help.

scripter73

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top