cf form hidden fields

I have a cf page that contains a form with a series of checkboxes...I display 10 checkboxes followed by buttons for Back, Next, and Close...the pages acts like a wizard in that it appears that it is going to different pages but of course its not...my question is...as the user clicks on the Next button, how do I retain the value from the checkboxes so that when the user reaches the last page and clicks Save, it has all the values from the previous pages checkboxes? Keep in mind, its the same page, I'm just reloading the same page when the user clicks Next or Back. I was thinking I need to use hidden fields in the form but I'm not sure of the syntax to use each time the page reloads.

Any thoughts, suggestions and/or code snippets would be appreciated.
thanks.
stacey14Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rob_lorentzCommented:

here is a template....

basically you need to use hidden fields.

<cfparam name="form.mode"            default="start">
<cfparam name="form.page"            default="1">
<cfparam name="form.action"            default="">
<cfparam name="form.BuyHow"            default="">
<cfparam name="form.existingCust" default="No">
<cfparam name="form.allowDisty" default="yes">
<cfparam name="form.agree"            default="No">
<cfparam name="form.eMsg"             default="">

<cfparam name="form.CfgNum"                  default="">
<cfparam name="form.CfgName"            default="">
<cfparam name="form.realCfgNum"            default="">
<cfparam name="form.UserPriceTotal" default="">
<cfparam name="form.psx_currency"      default="">
<cfparam name="form.reasonCode"            default="Pricing Not Available.">

<cfparam name="form.staticContactName" default="">
<cfparam name="form.contName"            default="">
<cfparam name="form.contCompany"      default="">
<cfparam name="form.contAddress"      default="">
<cfparam name="form.contCity"            default="">
<cfparam name="form.contState"            default="">
<cfparam name="form.contPostalCode"      default="">
<cfparam name="form.contPhone"            default="">
<cfparam name="form.contFax"            default="">
<cfparam name="form.contCountry"      default="">
<cfparam name="form.contEmail"            default="">

<cfparam name="form.poNum"                   default="">
<cfparam name="form.custNum"            default="">
<cfparam name="form.deliveryDate"       default="">
<cfparam name="form.startupDate"       default="">

<cfset form.contName = ltrim(rtrim(form.contName))>
<cfset form.contCompany = ltrim(rtrim(form.contCompany))>
<cfset form.contAddress = ltrim(rtrim(form.contAddress))>
<cfset form.contCity = ltrim(rtrim(form.contCity))>
<cfset form.contState = ltrim(rtrim(form.contState))>
<cfset form.contPostalCode = ltrim(rtrim(form.contPostalCode))>
<cfset form.contPhone = ltrim(rtrim(form.contPhone))>
<cfset form.contFax = ltrim(rtrim(form.contFax))>
<cfset form.contCountry = ltrim(rtrim(form.contCountry))>
<cfset form.contEmail = ltrim(rtrim(form.contEmail))>

<cfset variables.pageList = "pick,terms,instruct,contact,shipBill,po,confirm">
<cfset variables.showNext = "yes">

<cfif not len(form.realCfgNum)>
   <!--- I use this field as a flag to do my db query, its empty first time in
      <cfstoredproc procedure="sp_" datasource="dns">
            <cfprocparam dbvarname="CfgId" value="#SessionInfo.CfgId#" type="In" cfsqltype="CF_SQL_INTEGER">
            <cfprocparam dbvarname="SubId" value="0" type="In" cfsqltype="CF_SQL_INTEGER">
            <cfprocparam dbvarname="ShowDetail" value="0" type="In" cfsqltype="CF_SQL_INTEGER">
            <cfprocresult name="CfgInfo" resultset="1">
            <cfprocresult name="SubList" resultset="2">
      </cfstoredproc>
      <cfset form.CfgNum = cfgInfo.psxCfgNum>
      <cfset form.realCfgNum = cfgInfo.cfgNum>
      <cfset form.cfgName = cfgInfo.cfgName>
       <cfinclude template="inc_PSX_Calc_User_Price.cfm">
      <cfset form.UserPriceTotal = variables.UserPriceTotal>
      <cfset form.psx_currency = variables.psx_currency>
      <cfset form.reasonCode = variables.ReasonCode>
      <cfif listFindNoCase(valueList(subList.type),"B")>
            <cfset form.allowDisty = "No">
      </cfif>
</cfif>


<cfif len(form.action)>
      <cfif listFindNoCase("order,cancel,quit", form.action)>
            <cfif form.action is "order">
                       <!--- all done --->
                        <cfinclude template="saveStuff.cfm">
                         <cflocation url="confirationPage.cfm">
            </cfif>
      </cfif>
         <!--- here we do the validation checks for the various pages --->
      <cfswitch expression="#form.mode#">
            <cfcase value="pick">
                  <cfif not len(form.BuyHow)>
                        <cfset form.eMsg = "Select a purchase method.">
                        <cfset form.action = "">
                  </cfif>
            </cfcase>
            <cfcase value="terms">
                  <!--- insert record in psx_userLog --->
            </cfcase>
            <cfcase value="instruct">
            </cfcase>
            <cfcase value="contact">
                  <cfif form.action is "next">
                        <cfif not len(form.contName) or not len(form.contCompany) or not len(form.contAddress) or not len(form.contCity) or not len(form.contPostalCode)>
                              <cfset form.eMsg = "#form.eMsg#<li>Name, Company, Address, City, and Postal Code are all required fields. Please correct.">
                              <cfset form.action = "">
                        </cfif>
                        <cfif not len(form.contPhone) and not len(form.contEmail)>
                              <cfset form.eMsg = "#form.eMsg#<li>A phone number or valid E-mail address is required. Please correct.">
                              <cfset form.action = "">
                        </cfif>
                  </cfif>
            </cfcase>
            <cfcase value="po">
                  <cfif form.action is "next">
                        <cfif not len(form.POnum)>
                              <cfset form.eMsg = "#form.eMsg#<li>Please enter your purchase order number.">
                        </cfif>
                        <cfif len(form.deliveryDate) and len(form.startUpDate) and isDate(form.deliveryDate) and isDate(form.startupDate)>
                              <cfif dateDiff("d", now(), form.deliveryDate) lt 19 or dateCompare(form.deliveryDate, now()) lte 0>
                                    <cfset form.eMsg = "#form.eMsg#<li>Delivery date must be at least 20 days (#DateFormat(DateAdd("d",20,now()),"mm/dd/yyyy")#) from today. Please correct.">
                                    <!--- <cfset form.deliveryDate = DateFormat(DateAdd("d",20,now()),"mm/dd/yyyy")> --->
                              </cfif>
                              <cfif isDate(form.StartUpDate) and isDate(form.deliveryDate)>
                                    <cfif dateDiff("d", form.deliveryDate, form.startUpDate) lt 5 or dateDiff("d", dateAdd("d", 20, now()), form.startUpDate) lt 5>
                                          <cfset variables.tmpDeliveryDate = dateAdd("d", 25, now())>
                                          <cfif dateAdd("d", 5, form.deliveryDate) gt tmpDeliveryDate>
                                                <cfset variables.tmpDeliveryDate = dateAdd("d", 5, form.deliveryDate)>
                                          </cfif>
                                          <cfset form.eMsg = "#form.eMsg#<li>Start-Up date must be at least 5 days (#DateFormat(variables.tmpDeliveryDate,"mm/dd/yyyy")#) from the Delivery Date. Please correct.">
                                          <!--- <cfset form.startupDate = DateFormat(DateAdd("d", 5, form.deliveryDate), "mm/dd/yyyy")> --->
                                    </cfif>                              
                              </cfif>
                        <cfelseif len(form.deliveryDate) or len(form.startUpDate)>
                              <cfset form.eMsg = "#form.eMsg#<li>Either both delivery and start-up dates must be entered or both must be left blank. Please correct.">
                              <cfif not isDate(form.deliveryDate)>
                                    <cfset form.eMsg = "#form.eMsg#<li>Please enter a requested delivery date. Enter the date as month/day/year. Example #DateFormat(DateAdd("d",20,now()),"mm/dd/yyyy")#">
                              </cfif>
                              <cfif not isDate(form.startupDate)>
                                    <cfset form.eMsg = "#form.eMsg#<li>Please enter a requested start-up date. Enter the date as month/day/year. Example #DateFormat(DateAdd("d",25,now()),"mm/dd/yyyy")#">
                              </cfif>
                        </cfif>
                        <cfif len(form.eMsg)><cfset form.action = ""></cfif>
                  <cfelseif form.action is "assist">
                        <cfset form.eMsg = "<li>Your request for assistance has been sent. An custpomer representative will contact you shortly.">
                        <cfset form.action = "">
                  </cfif>
            </cfcase>
      </cfswitch>
      <cfif form.action is "next">
            <cfset form.page = form.page + 1>
      <cfelseif len(form.action)>
            <cfset form.page = form.page - 1>
      </cfif>
      <cfset form.mode = listgetat(variables.pageList, form.page)>
</cfif>


<cfif form.mode is "start">


<!--- Body --->
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
      <tr>
            <form name="frmPurchasing" action="PSX_Purchasing.cfm" method="POST">
            <cfoutput>
                  <input type="hidden" name="action" value="" />
                  <input type="hidden" name="mode" value="#form.mode#" />
                  <input type="hidden" name="allowDisty" value="#form.allowDisty#" />
                  <input type="hidden" name="page" value="#form.page#" />
                  <input type="hidden" name="existingCust" value="#form.existingCust#" />
                  <input type="hidden" name="staticContactName" value="#form.staticContactName#" />
                  <input type="hidden" name="cfgNum" value="#form.cfgNum#" />
                  <input type="hidden" name="realCfgNum" value="#form.realCfgNum#" />
                  <input type="hidden" name="cfgName" value="#form.cfgName#" />
                  <input type="hidden" name="UserPriceTotal" value="#form.UserPriceTotal#" />
                  <input type="hidden" name="psx_currency" value="#form.psx_currency#" />
                  <input type="hidden" name="ReasonCode" value="#form.reasonCode#" />
                  
                  <cfif form.mode is not "pick">
                        <input type="hidden" name="buyHow" value="#form.buyHow#" />
                  </cfif>
                  <cfif not listFindNoCase("contact,confirm", form.mode)>
                        <input type="hidden" name="contCompany" value="#form.contCompany#" />
                        <input type="hidden" name="contName" value="#form.contName#" />
                        <input type="Hidden" name="contAddress" value="#form.contAddress#" />
                        <input type="hidden" name="contCity" value="#form.contCity#" />
                        <input type="Hidden" name="contState" value="#form.contState#" />
                        <input type="hidden" name="contPostalCode" value="#form.contPostalCode#" />
                        <input type="Hidden" name="contCountry" value="#form.contCountry#" />
                        <input type="hidden" name="contPhone" value="#form.contPhone#" />
                        <input type="hidden" name="contFax" value="#form.contFax#" />
                        <input type="hidden" name="contEmail" value="#form.contEmail#" />
                  </cfif>
                  <cfif not listFindNoCase("po,confirm", form.mode)>
                        <input type="hidden" name="poNum" value="#form.poNum#" />
                        <input type="hidden" name="custNum" value="#form.custNum#" />
                        <input type="hidden" name="deliveryDate" value="#form.deliveryDate#" />
                        <input type="hidden" name="startupDate" value="#form.startupDate#" />
                  </cfif>
            </cfoutput>
            <td width="100%">
                  <table border="0" cellpadding="0" cellspacing="2" width="700px" align="center">
                        <cfif len(sessionInfo.msg)>
                              <tr style="padding-top:5px;padding-bottom:5px;">
                                    <td colspan="2"><cf_PSX_ShowSessionMsg Msg ="#SessionInfo.Msg#" Id ="#SessionInfo.Id#" PadBot = "Yes"></td>
                              </tr>
                              <tr><td colspan="2"><img src="/resource/images/invisible.gif" width="10" height="10px" alt="" border="0" /></td></tr>
                        </cfif>
                        <cfif len(form.eMsg)>
                              <tr><td colspan="2" class="red"><cfoutput>#form.eMsg#</cfoutput></td></tr>
                              <tr><td colspan="2"><img src="/resource/images/invisible.gif" width="10" height="10px" alt="" border="0" /></td></tr>
                        </cfif>
                        <cfswitch expression="#form.mode#">
                              <cfcase value="pick">
                                    <cfinclude template="include\PSX_Purchase\dsp_PSX_Purchase_BuyHow.cfm">
                              </cfcase>
                              <cfcase value="terms">
                                    <cfinclude template="include\PSX_Purchase\dsp_PSX_Purchase_TermsConditions.cfm">
                              </cfcase>
                              <cfcase value="instruct">
                                    <cfinclude template="include\PSX_Purchase\dsp_PSX_Purchase_Instructions.cfm">
                              </cfcase>
                              <cfcase value="shipBill">
                                    <cfinclude template="include/PSX_Purchase/dsp_PSX_Purchase_ShipBill.cfm">
                              </cfcase>
                              <cfcase value="contact">
                                    <cfinclude template="include/PSX_Purchase/dsp_PSX_Purchase_Contact.cfm">
                              </cfcase>
                              <cfcase value="po">
                                    <cfinclude template="include\PSX_Purchase\dsp_PSX_Purchase_PO.cfm">                                    
                              </cfcase>
                              <cfcase value="confirm">
                                    <cfinclude template="include\psx_purchase\dsp_PSX_Purchase_Confirmation.cfm">
                              </cfcase>
                              
                        </cfswitch>
                        <tr><td colspan="2"><img src="/resource/images/invisible.gif" width="1" height="25px" alt="" border="0" /></td></tr>
                  </table>
            </td>
            </form>
      </tr>

</table>



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.