EasyCFM.COM ColdFusion Forums / Tutorial Requests! / 2 page forms

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: 2 page forms

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

gryny
02-22-2006 @ 12:52 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 1
Joined: Feb 2006

Hi guys,

Does anybody know how to carry form informations from first page to second page without submitting them to table.I have 2 page table and every time when I want to go second page(like submit first page)information goes to database. I don't know how to carry them to second page and submit it.Thank You.   gryny@hotmail.com

mquack
02-22-2006 @ 1:44 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1544
Joined: Jan 2005

Not sure I understand the question, but if I do...

Don't run an insert query on the first submission.  Instead use hidden formfields populated with the info from the first form, and send it on to the second submission page.

http://www.rachelqueensg.com

maquiladoras
02-22-2006 @ 7:34 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2073
Joined: Dec 2002

yeah you can either have the second page create hidden form fields, like mquack said

ie <input type="hidden" name="myField" value="#form.myField#">

or you could store it in a session field, or if you want them to be able to come back later, you could store it in a cookie

-
Any code printed thus far is likely to be stolen and used by Ray Horn, well done...ray
-

kevsarg18
03-13-2006 @ 6:57 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 428
Joined: Jun 2004

i like the session method, lets the user travel the form pages and make edits much easier, especially more than 2 pages.

My CFML Scripts.

WJMeyer
10-31-2006 @ 2:44 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 5
Joined: Oct 2006

Definately, I think the session variable idea is the best.

vlakbbo
10-31-2006 @ 8:52 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 20
Joined: Mar 2006

Here's a simple page using a Structure and scoping it into a session. Something to build on. Going with the components would be my route though...


<cfparam name="form.step" default="1">
<cfif isdefined("url.step")>
     <cfset form.step = 2>
</cfif>
<!--- Create the structure if it doesnt' exist and scope it into a session --->
<cfif not isdefined("Session.FormData")>
     <cfscript>
          Session.FormData = StructNew();
          Session.FormData.ID = "#Rand("SHA1PRNG")#" ;
          Session.FormData.Userid = "" ;
          Session.FormData.Password = "" ;
          Session.FormData.FirstName = "";
          Session.FormData.LastName = "";
     </cfscript>
</cfif>




<cfswitch expression="#form.step#">
     <cfcase value="1">
          <!--- First Form --->
          <form method="post" name="Form">
          <input type="hidden" value="2" name="Step">
          Enter a Userid : <input type="text" value="" name="Userid"><br>
          Enter a Password : <input name="password" type="password"><br>
          <input type="submit" name="Submit"  value="Next" onClick="InsertData();">
          </form>
          <cfdump var="#Session.FormData#">
     </cfcase>


     <cfcase value="2">
          <!--- Script to insert first form data into structure --->
          <cfscript>
               if(isdefined("form.Userid") AND Len(Form.Userid)){
                    Session.FormData.Userid = #Form.Userid#;
               }
               if(isdefined("form.Password") AND Len(Form.Password)){
                    Session.FormData.Password = #Form.Password#;
               }
          </cfscript>

          <!--- Second Form --->
          <p><a href="index.cfm">Go Back</a></p>
          <form method="post" name="Form">
          <input type="hidden" value="3" name="step">
          First Name : <input type="text" value="" name="FirstName">
          Last Name : <input type="text" value="" name="LastName">
          <input type="submit" name="Submit"  value="Next">
          </form>
          <cfdump var="#Session.FormData#">
     </cfcase>
     
     <cfcase value="3">
          <!--- Script to insert first form data into structure --->
          <cfscript>
               if(isdefined("form.FirstName") AND Len(Form.FirstName)){
                    Session.FormData.FirstName = #Form.FirstName#;
               }
               if(isdefined("form.LastName") AND Len(Form.LastName)){
                    Session.FormData.LastName = #Form.LastName#;
               }
          </cfscript>
          <p><a href="index.cfm?step=2">Go Back</a></p>
          <form method="post" name="Form">
               <input type="hidden" value="4" name="step">
               <input type="submit" name="Submit"  value="SAVE">
          </form>
          <cfdump var="#Session.FormData#">
     </cfcase>


     <cfcase value="4">
          <!--- Insert the sql INSERT Statement with the Session.FormData values --->
          <p><strong>Record Saved Successfully</strong></p>
     </cfcase>
</cfswitch>










Website Designed and Developed by Pablo Varando.