cf form hidden fields

Posted on 2005-03-16
Medium Priority
Last Modified: 2013-12-24
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.
Question by:stacey14
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 10

Accepted Solution

rob_lorentz earned 375 total points
ID: 13559280

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">
      <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 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">
         <!--- 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 = "">
            <cfcase value="terms">
                  <!--- insert record in psx_userLog --->
            <cfcase value="instruct">
            <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 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 = "">
            <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 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 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)>
                                          <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")> --->
                        <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 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 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 form.action is "next">
            <cfset form.page = form.page + 1>
      <cfelseif len(form.action)>
            <cfset form.page = form.page - 1>
      <cfset form.mode = listgetat(variables.pageList, form.page)>

<cfif form.mode is "start">

<!--- Body --->
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
            <form name="frmPurchasing" action="PSX_Purchasing.cfm" method="POST">
                  <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 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 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#" />
            <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><td colspan="2"><img src="/resource/images/invisible.gif" width="10" height="10px" alt="" border="0" /></td></tr>
                        <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>
                        <cfswitch expression="#form.mode#">
                              <cfcase value="pick">
                                    <cfinclude template="include\PSX_Purchase\dsp_PSX_Purchase_BuyHow.cfm">
                              <cfcase value="terms">
                                    <cfinclude template="include\PSX_Purchase\dsp_PSX_Purchase_TermsConditions.cfm">
                              <cfcase value="instruct">
                                    <cfinclude template="include\PSX_Purchase\dsp_PSX_Purchase_Instructions.cfm">
                              <cfcase value="shipBill">
                                    <cfinclude template="include/PSX_Purchase/dsp_PSX_Purchase_ShipBill.cfm">
                              <cfcase value="contact">
                                    <cfinclude template="include/PSX_Purchase/dsp_PSX_Purchase_Contact.cfm">
                              <cfcase value="po">
                                    <cfinclude template="include\PSX_Purchase\dsp_PSX_Purchase_PO.cfm">                                    
                              <cfcase value="confirm">
                                    <cfinclude template="include\psx_purchase\dsp_PSX_Purchase_Confirmation.cfm">
                        <tr><td colspan="2"><img src="/resource/images/invisible.gif" width="1" height="25px" alt="" border="0" /></td></tr>



Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question