• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Capturing a URL varible to a hidden field

LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

I am trying to pass 2 variables to a hidden fields on the next page. I then
want to use them in the code after then submit button is clicked.

I passed the 2 variables correctly though the URL and can capture one for
text on the page using:
<cfoutput>#URL.username#</cfoutput>

However, they are not working in the hidden fields. I have:

<cfoutput><input name="username" type="hidden" id="username"
value="#URL.username#" /> <input name="email" type="hidden" id="email"
value="#URL.email#" /></cfoutput>

Please help!

--
Wally Kolcz
Developer / Support
ProjectProofing.com


TOPICS
Advanced techniques

Views

975

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

No obvious errors here, how is this "not working?" What incorrect
behavior|errors is happening?

Wally Kolcz wrote:
> I am trying to pass 2 variables to a hidden fields on the next page. I then
> want to use them in the code after then submit button is clicked.
>
> I passed the 2 variables correctly though the URL and can capture one for
> text on the page using:
> <cfoutput>#URL.username#</cfoutput>
>
> However, they are not working in the hidden fields. I have:
>
> <cfoutput><input name="username" type="hidden" id="username"
> value="#URL.username#" /> <input name="email" type="hidden" id="email"
> value="#URL.email#" /></cfoutput>
>
> Please help!
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

On the IsDefined('Submit') I have:
<cfdirectory action="CREATE"
directory="E:\webs\mywebsite.com\#form.username#">

It keeps coming up with the literal #FORM.username# and creates a folder
called #form.username# verses the value that is captured in the hidden
field.

When I switch it to #URL.username# it seems to work.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

What is the method parameter on the form page. If method is "get" then
you are sending the data as URL data not Form data which is method="post"

Wally Kolcz wrote:
> On the IsDefined('Submit') I have:
> <cfdirectory action="CREATE"
> directory="E:\webs\mywebsite.com\#form.username#">
>
> It keeps coming up with the literal #FORM.username# and creates a folder
> called #form.username# verses the value that is captured in the hidden
> field.
>
> When I switch it to #URL.username# it seems to work.
>
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

Agreed, but if I were to capture the URL variable into a hidden field,
wouldn't that make it a form variable to which I could use Form.?


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

if your form's method is GET, then you access the variables using URL._____
if your form's method is POST, then you access the variables using FORM._____

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

LATEST
Oh, btw, the form is set to 'post' and the Form. was not working..

That is why I am confused.

Thanks


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

NOPE. What the values of a form are returned to the server as is solely
determined by the method parameter of the form.

Some code you can play with that might clear this up.

<cfsilent>

<cfparam name="url.Field" default="">
<cfparam name="form.Field" default="">

</cfsilent><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Form Methods</title>
</head>

<body>
<h1>Form Methods</h1>

<h2>Get</h2>
<cfoutput>
<form method="Get">
<input type="text" name="Field" value="#form.field#" />
<input type="submit" />
</form>

<h2>Post</h2>
<form method="post">
<input type="text" name="Field" value="#url.Field#" />
<input type="submit" />
</form>
</cfoutput>
</body>
</html>

Wally Kolcz wrote:
> Agreed, but if I were to capture the URL variable into a hidden field,
> wouldn't that make it a form variable to which I could use Form.?
>
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

To follow up, when submitting the Get form, notice that the value is now
in the URL of the page.

Ian Skinner wrote:
> NOPE. What the values of a form are returned to the server as is solely
> determined by the method parameter of the form.
>
> Some code you can play with that might clear this up.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

I understand what you mean. Thanks.

Is it possible to reference a hidden variable after it has captured its
value from the URL?

If I have my hidden variable 'email' set to =#URL.email# can I reference
that in a <cfmail> after the form is submitted?
<cfoutput><input name="email" type="hidden" id="email" value="#URL.email#"
/></cfoutput>

Or is it better to just <cfset emailfrom = #URL.email#> then use that in the
<cfmail> area after the form is submitted?

I have the form set to:
<cfif IsDefined('submit')>
Create Dyanmic Folder
Copy File Into Folder
Send Email with attachent
INSERT form into database
UPDATE another database
Redirect to 'thank you page'
</cfif>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation