INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Pass variables to another page then have the submit
2

Share

Pass variables to another page then have the submit

Pass variables to another page then have the submit

(OP)
I have a one web page form that takes Visitor information and works great where it processes the information on the form and sends the information to an email address.

Now I need to add an optional 5 more Visitor entries to my form which I would like to put an optional "next page" so the form is not too long.  How can I pass all my variables from the first page to the next page and have the submit button on the next page?

So at the bottom of my first page will be the original submit button for the first page of visitor information and an option to go to another page to add more visitors so the user can add addtional visitors on the next page.   After filling out the visitors for the second page they can hit the submit button and send the information for all the visitors from the first and second page.   

RE: Pass variables to another page then have the submit

Put this code inside the form on your second page:

<cfif IsDefined("form.frompageone")>
<cfoutput><cfloop index="thisval" list="#form.fieldnames#">
<cfset field=thisval>
<cfset fieldval = evaluate("form.#thisval#")>
<input type="hidden" name="#field#" value="#fieldval#">
</cfloop></cfoutput>

</cfif>
It carries all of the form variables and their values over to hidden fields in the next form.
The submit button on page one has to be named "frompageone". Plus this can't be a self-submitting form because you'd just mulitply the hidden values.

HTH,

Phil Hegedusich
Senior Web Developer
IIMAK
http://www.iimak.com
-----------
A priest, a lawyer, and a rabbi walk into a bar.  The bartender looks up and says "What is this, a joke?"

RE: Pass variables to another page then have the submit

(OP)
Thanks I have the first parts working where I get to page two as you stated but not sure how to pull up the values on the action page?

First page:

CODE

<form action="formThree.cfm" method="post">
<input type="Text" name="nameOne">
<input type="Text" name="nameTwo">

<input type="Submit" value="frompageone">
</form>
Second Page:

CODE

<form action="theActionpage.cfm" method="post">
<cfif IsDefined("form.frompageone")>
<cfoutput><cfloop index="thisval" list="#form.fieldnames#">
<cfset field="thisval">
<cfset fieldval = evaluate("form.#thisval#")>
<input type="hidden" name="#field#" value="#fieldval#">
</cfloop></cfoutput>
</cfif>
<input type="Text" name="nameThree">
<input type="Submit">
</form>

The action page error message:

An error occurred while evaluating the expression:
#fieldval#
Error near line 11, column 8.


The action page:

CODE

here it is:<br>
<cfoutput>
nameOne = #fieldval#<br>
nameTwo = #fieldval#<br>
nameThree = #nameThree#
</cfoutput>

Please advise.

RE: Pass variables to another page then have the submit

Try this:

CODE

<cfoutput>
nameOne = #form.nameOne#<br>
nameTwo = #form.nameTwo#<br>
nameThree = #form.nameThree#
</cfoutput>

Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher

RE: Pass variables to another page then have the submit

(OP)
I tried that and it still gives me the same type of error.

CODE

<cfoutput>
nameOne = #form.nameOne#<br>
nameTwo = #form.nameTwo#<br>
nameThree = #form.nameThree#
</cfoutput>

Any other suggestions?

RE: Pass variables to another page then have the submit

<cfset field="thisval">
should be
<cfset field = thisval>

when you evaluate the expression the way you have it you're looking for the value of "form.thisval" which doesn't exist so it wouldn't be defined, hence your error.

Good luck.

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)

RE: Pass variables to another page then have the submit

one thing that may or may not fix the problem is

<cfset field="thisval">
should be
<cfset field=thisval>

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)

RE: Pass variables to another page then have the submit

sorry either my connection hung up or TT hung up and I didn't see the original post.

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)

RE: Pass variables to another page then have the submit

(OP)
Thanks,
I tried as you suggested and it still gives me the same error.

I have also tried many variations of the the output but cant get it to work.

RE: Pass variables to another page then have the submit

ok, I don't see how
<cfif IsDefined("form.frompageone")>
is ever true if you have
<input type="Submit" value="frompageone">
in the first form.
frompageone needs to be the NAME of the submit button. not the value.

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)

RE: Pass variables to another page then have the submit

Ok, let's back up and start over.  On your second page (where you want to pass the info from the first form), try using this instead of what you currently have:

CODE

<cfoutput>
  <cfloop list="#form.fieldnames#" index="f">
    <input type="hidden" value="#jsstringformat(FORM[f])#" name="#f#">
  </cfloop>
</cfoutput>
If you view the source of that page, you should see:

CODE

<input type="hidden" name="nameOne" value="Whatever">
<input type="hidden" name="nameTwo"" value="Whatever">
with the values that you entered in on the first form.  Once you submit the second form (to your action page), you should just be able to reference the values from your first form as #Form.nameOne# and #Form.nameTwo#.

Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher

RE: Pass variables to another page then have the submit

(OP)

Thanks to both of you it now works.

I looked up jsstringformat and it says it returns a string.
But I dont understand the argument FORM[f]
Can someone please explain that part??

RE: Pass variables to another page then have the submit

Since you're looping through the list of field names from the first form:

CODE

<cfloop list="#form.fieldnames#" index="f">
the cfloop just assigns the form field names an "alias" of "f", so any time during the loop, #f# would produce the field names.

It's just a way of looping through without having to say: Form.nameOne, Form.nameTwo, Form.nameThree...etc...

Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher

RE: Pass variables to another page then have the submit

its another way to acces the "form" scope  similar to if you were going to do a collection loop.

CODE

<cfloop collection="#form#" item="fieldValue">
<cfoutput>
<cfif fieldValue neq "FIELDNAMES">
<tr>
<td>#fieldvalue#</td>
<td><cfif form[fieldValue] eq "">
Empty String                      
<cfelse>#form[fieldValue]#</cfif></td>
</tr>
</cfif>
</cfoutput>
</cfloop>

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)

RE: Pass variables to another page then have the submit

I knew that was going to happen ecobb

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)

RE: Pass variables to another page then have the submit

Always does...

Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher

RE: Pass variables to another page then have the submit

(OP)
Again, thanks for all your time and helping me with this!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close