Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

cf form hidden fields

Posted on 2005-03-16
1
Medium Priority
?
273 Views
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.
thanks.
0
Comment
Question by:stacey14
1 Comment
 
LVL 10

Accepted Solution

by:
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">
      </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

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

580 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