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

Coldfusion-Passing form data via Anchor

Status
Not open for further replies.

cfnewbie5

Programmer
Oct 6, 2003
5
US
Greetings All!
I am hoping that someone out there can possibly help me!

I am trying to pass date range information keyed on a form page to an action page when a user clicks on an anchor. The error I keep getting is that the form field is not found.

If someone can help me or point me in the right direction,
it would be greatly appreciated!

The code defining the field is:
<td width=&quot;19%&quot;>Start Visit Date: <br></td>
<td width=&quot;31%&quot;>
<cfinput type=&quot;text&quot; name=&quot;start_dte_range&quot; size=&quot;9&quot;
maxlength=&quot;10&quot; value=&quot;&quot;>

The code defining the link is:
<td colspan=&quot;4&quot; height=&quot;27&quot; align=&quot;center&quot; title=&quot;By date&quot;>
<a href=&quot;my_template.cfm?url_sdr=#URLEncodedFormat(start_dte_range)#&quot;>

<font color=&quot;FF00FF&quot;>Survey Report by Date</font></a>

The Error message I receive is:
&quot;Error Occurred While Processing Request
Variable START_DTE_RANGE is undefined. &quot;

 
The information is not going to be passed to the next page unless you submit the form somehow. As you currently have it set up, you just have a link to the page and it's not passing any of the form information. You have to remember, when the page is first loaded the <a href=&quot;my_template.cfm?url_sdr=#URLEncodedFormat(start_dte_range)#&quot;> is going to be populated with the CURRENT value of the the start_dte_range variable. This is what will be passed to the form action page, regardless of what's put in the <input> box.

You may can try something like this:
1) Set up your form just like you would if you were using a &quot;submit&quot; button.
2) Throw in this little line of JavaScript. (inside your <form></form> tags)

<script>
function submitForm() {
document.forms[0].submit();
}
</script>

3) And then your text link, referencing the above JavaScript
<a href=&quot;my_template.cfm&quot; onClick=&quot;submitForm()&quot;>Survey Report by Date</a>

Hopefully, that should work. I don't know, I haven't tested it, but I know the above works on images and buttons for me, so it should work on text links...I hope.... :)

Hope This Helps!

Ecobb
- I hate computers!
 
Thanks All!
And a special thanks to Ecobb! That did the trick but I
was hoping for a more direct route than the intermediary
step to access the form variables.

Thanks Again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top