|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simple transfer of data from form to form
I would like to create a basic form that passes form data from one to the next and so on until I end it with a CFmail to. I am new to coding and know this is a very basic one.
Also, anyone have any good books to reference on beginners in CF coding? Thanks, kdiff |
|
#2
|
|||
|
|||
|
When you post a form to another CF page, the form data is available to the target page in the FORM scope. So if your form has a field called "firstName" and you post that form to another CF page, you can reference that data as "form.firstName". For example, to output it:
<cfoutput> #form.firstName# </cfoutput> There are many good CF books, but the "bible" is Ben Forta's book. |
|
#3
|
|||
|
|||
|
What if I want multiple pages
Everything you said makes sense. I will try it. If I want to transfer data from my first from page to the third would I just put the CF output on the second page as well? Basically does that continue from one page to another?
Thanks for all your help! |
|
#4
|
|||
|
|||
|
Well, if you transfer from the first page to the third page, doesn't the third page become the "second page"? Each web request is stateless and self-contained. You could post the form to one of any number of different ColdFusion templates and the FORM scoped data would be available on whichever one you posted to. If you copied the data in the FORM scope into form fields on the target page, and then posted THAT form to yet another page, the values would carry over. In other words, you have to take responsibility for moving the variables from page to page either manually or by looping over the data in the FORM scope and dynamically creating form fields.
Another option is to use the SESSION scope, which is a persistent, memory-resident scope that is independent of individual page requests. But I would read through Forta's book or a similar overview before attempting too much more. |
|
#5
|
|||
|
|||
|
Reply to Kiteless
I guess I should have described what I was saying a little better. I was asking if I had 3 pages and I wanted to take the data from page 1 to page 2 and then the data from page one and 2 to page 3 could I do that in the same way you described previously?
Also, could you give me the exact name of that book by ben forta? I did a search for it in Amazon and did not see a "cold fusion bible" Thanks, -kdiff Last edited by kdiff : March 3rd, 2004 at 08:47 PM. Reason: One more thought... |
|
#6
|
|||
|
|||
|
construction kit
what you might be trying to do is something like this place this within your form and it should pass you previously submitted fields to the subsequently submitted pages The <cfset ListDontDuplicate = "Submit"> part is so that you can remove the submit button form the forwarded list <cfparam name="form.FIELDNAMES" default=""> <cfset ListDontDuplicate = "Submit"> <cfloop list="#form.FIELDNAMES#" index="i"> <cfif listfind(ListDontDuplicate,i) eq 0> <cfoutput><input type="Hidden" name="#i#" value="#evaluate('form.'&i)#"></cfoutput> </cfif> </cfloop> |
|
#7
|
|||
|
|||
|
Closer but not working
Ok Here are my three pages. How do people normally do multipage questionaires? In any case here is my code. You will be able to see just how much I know (which is not much) but I do have a desire to learn and will be buying that book.
Page 1 <body> <form name="form1" method="post" action="form2.cfm"> <p> <input name="email" type="text" id="email"> </p> <p> <input name="Next" type="submit" id="Next" value="next"> </p> </form> </body> Page 2 <body> <form name="form2" method="post" action="form_send.cfm"> <p><cfparam name="form.email" default=""> <cfset ListDontDuplicate = "Submit"> <cfloop list="#form.email#" index="i"> <cfif listfind(ListDontDuplicate,i) eq 0> <cfoutput><input type="Hidden" name="##" value="#evaluate('form.'&i)#"></cfoutput> </cfif> </cfloop> <input name="box1" type="text" id="box1"> </p> <p> <input name="Next" type="submit" id="Next" value="next"> </p> </form> </body> Page 3 <p><font size="3">Thank you for your message. If necessary we will respond in a timely manner.</font><!--- END Body ---> <cfparam name="email" default=""> <cfparam name="box1" default=""> <cfmail to="test@test.com" from="#email#" subject="maintenance request form" type="html"> <tr> <td valign="top"><font face="arial,helvetica" size="-1"><b>email:</b></td> <td valign="top"><font face="arial,helvetica" size="-1">#email#</td> </tr> <tr> <td valign="top"><font face="arial,helvetica" size="-1"><b>box1:</b></td> <td valign="top"><font face="arial,helvetica" size="-1">#box1#</td> </tr> </table> </cfmail> What do you think? |
|
#8
|
|||
|
|||
|
On page 2, this:
<cfloop list="#form.email#" index="i"> Should be: <cfloop list="#form.FIELDNAMES#" index="i"> And this: <cfoutput><input type="Hidden" name="##" value="#evaluate('form.'&i)#"></cfoutput> Should be this (note that you don't need to use evaluate here as stpaz suggested...avoid using evaluate() if at all possible): <cfoutput><input type="Hidden" name="#i#" value="#form[i]#"></cfoutput> Other than that, I don't see any other problems upon a quick overview. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Simple transfer of data from form to form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|