Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CF - trying to hide a form after submit

Posted on 2011-03-23
13
Medium Priority
?
414 Views
Last Modified: 2012-05-11
I am trying to use the <cfset showForm = false> to not display the form after it is submitted.  The form appears in a iFrame and after the submit I want just the message to display.  THe obvious problem is that the message and the form display so how does the showForm false work?

Thanks
0
Comment
Question by:JohnMac328
[X]
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
  • 6
  • 6
13 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 35200628
all you can do is this.

<cfif not isdefined(form.butonSubmitname)>

then show form

<cfelse>

Message goes here


</cfif>
0
 

Author Comment

by:JohnMac328
ID: 35200747
I changed my logic to <cfif not isdefined(form.butonSubmitname)> but the <cfelse> did not fit in with all the checking I am doing - can you see where it would fit in?
<!--- If the form is submitted --->
<!--- <cfif isDefined("FORM.Submit")> --->
<cfif not isdefined("FORM.Submit")>

<!---    <cfset strError = ""> --->


      <cfset FORM.Email = Trim(FORM.Email)>
      <cfif Len(Trim(FORM.Email)) LT 1>
      <cfset strError = strError & "Please enter your Email!<br>">
      </cfif>
       
      <cfif not len(strError)>    
         <CFQUERY NAME="GetEmail" DATASOURCE="#datasource#">
           SELECT  Email
           FROM    SubscriptionIA
           WHERE email = <CFQUERYPARAM VALUE="#FORM.EMAIL#" CFSQLTYPE="CF_SQL_VARCHAR">
        </CFQUERY>

        <cfif GetEmail.recordcount GT 0>
          <cfset strError = strError & "That email is already registered <br>to receive the newsletter<br>">
        <cfelse>
           <cfquery  NAME="Added" datasource="#datasource#">
            INSERT INTOTable (Email,firstname, lastname, FUND, GROW)
            VALUES ('#FORM.Email#','#FORM.firstname#','#FORM.lastname#','#FORM.FUND#','#FORM.GROW#')
            </cfquery>
		   <cfelse>
		   <h5>Thank You for Signing up for our Newsletter!</h5>
		   <p>You should start receiving the Newsletter soon.</p>
           </cfif>

Open in new window

0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 35200793
whatever you doing there is happening only when the submit button is clicked so change the condition to this <cfif isdefined("FORM.Submit")>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:JohnMac328
ID: 35200822
Then it blows up on the <cfelse> - I changed it to <cfif isDefined("FORM.Submit")>

Context validation error for the cfelse tag.  
The tag must be nested inside a CFIF tag.  
 
The error occurred in C:\Inetpub\wwwroot\JQUERY_EMAIL_SIGNUP\IA_signup.cfm: line 42
 
40 :             VALUES ('#FORM.Email#','#FORM.firstname#','#FORM.lastname#','#FORM.FUND#','#FORM.GROW#')
41 :             </cfquery>
42 :                <cfelse>

 
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 35200881
you unclosed <cfif > statement, can you post the entire code
0
 

Author Comment

by:JohnMac328
ID: 35200918
Here is a more complete listing
<cfset datasource = "Hbanana">
 <cfparam name="FORM.Email" default="">
 <cfparam name="FORM.firstname" default="">
 <cfparam name="FORM.lastname" default="">
 <cfparam name="FORM.FUND" default="">
 <cfparam name="FORM.GROW" default=""> 

<!--- Create an empty error string --->
<cfset strError = "">

<!--- If the form is submitted --->
<cfif isDefined("FORM.Submit")> 
<!--- <cfif not isdefined("FORM.Submit")> --->

<!---    <cfset strError = ""> --->


      <cfset FORM.Email = Trim(FORM.Email)>
      <cfif Len(Trim(FORM.Email)) LT 1>
      <cfset strError = strError & "Please enter your Email!<br>">
      </cfif>
       
      <cfif not len(strError)>    
         <CFQUERY NAME="GetEmail" DATASOURCE="#datasource#">
           SELECT  Email
           FROM    Table
           WHERE email = <CFQUERYPARAM VALUE="#FORM.EMAIL#" CFSQLTYPE="CF_SQL_VARCHAR">
        </CFQUERY>

        <cfif GetEmail.recordcount GT 0>
          <cfset strError = strError & "That email is already registered <br>to receive the newsletter<br>">
        <cfelse>
           <cfquery  NAME="Added" datasource="#datasource#">
            INSERT INTO Table (Email,firstname, lastname, FUND, GROW)
            VALUES ('#FORM.Email#','#FORM.firstname#','#FORM.lastname#','#FORM.FUND#','#FORM.GROW#')
            </cfquery>
		   <cfelse>
		   <h5>Thank You for Signing up for our Newsletter!</h5>
		   <p>You should start receiving the  Newsletter!soon.</p>
           </cfif>
           
<!---   <cfset strError = "Added to the newsletter<br>">  --->
		<cfmail>
Mail to send
   </cfmail>  
		</cfif>
     </cfif>
</cfif>

Open in new window

0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 35200985
try this this should work .You have an extra <cfele< and </cfif>


<cfset datasource = "Hbanana">
 <cfparam name="FORM.Email" default="">
 <cfparam name="FORM.firstname" default="">
 <cfparam name="FORM.lastname" default="">
 <cfparam name="FORM.FUND" default="">
 <cfparam name="FORM.GROW" default="">

<!--- Create an empty error string --->
<cfset strError = "">

<!--- If the form is submitted --->
<cfif isDefined("FORM.Submit")>
<!--- <cfif not isdefined("FORM.Submit")> --->

<!---    <cfset strError = ""> --->


      <cfset FORM.Email = Trim(FORM.Email)>
            <cfif Len(Trim(FORM.Email)) LT 1>
            <cfset strError = strError & "Please enter your Email!<br>">
            </cfif>
       
      <cfif not len(strError)>    
         <CFQUERY NAME="GetEmail" DATASOURCE="#datasource#">
           SELECT  Email
           FROM    Table
           WHERE email = <CFQUERYPARAM VALUE="#FORM.EMAIL#" CFSQLTYPE="CF_SQL_VARCHAR">
        </CFQUERY>

        <cfif GetEmail.recordcount GT 0>
          <cfset strError = strError & "That email is already registered <br>to receive the newsletter<br>">
        <cfelse>
           <cfquery  NAME="Added" datasource="#datasource#">
            INSERT INTO Table (Email,firstname, lastname, FUND, GROW)
            VALUES ('#FORM.Email#','#FORM.firstname#','#FORM.lastname#','#FORM.FUND#','#FORM.GROW#')
            </cfquery>
             
               <h5>Thank You for Signing up for our Newsletter!</h5>
               <p>You should start receiving the  Newsletter!soon.</p>
           </cfif>
           
<!---   <cfset strError = "Added to the newsletter<br>">  --->
            <cfmail>
Mail to send
         </cfmail>  
            </cfif>
     </cfif>
0
 

Author Comment

by:JohnMac328
ID: 35201040
It runs but now I am back to trying to get the form to not show after a submit goes through
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 35201064
just after you display your message put a button that will you take back to the form

SOme this ng like this

<input type='button' name="btnback" onclick="location.replace('filename');">
0
 

Author Comment

by:JohnMac328
ID: 35201512
After the form is submitted, I want just the message to show and not the form.
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 35201643
so then what is the question ?
0
 

Author Comment

by:JohnMac328
ID: 35201785
Actually my original question is how to get the showform = false to work.  They want the message to appear in the iFrame after the form has been submitted, when the button is clicked - the form no longer shows and just the confirmation message appears.  What it is doing now is showing the message and the form.
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 2000 total points
ID: 35290102
use <cfexit> to stop processing after the form submit
<cfset datasource = "Hbanana">
 <cfparam name="FORM.Email" default="">
 <cfparam name="FORM.firstname" default="">
 <cfparam name="FORM.lastname" default="">
 <cfparam name="FORM.FUND" default="">
 <cfparam name="FORM.GROW" default=""> 

<!--- Create an empty error string --->
<cfset strError = "">

<!--- If the form is submitted --->
<cfif isDefined("FORM.Submit")> 
      <cfset FORM.Email = Trim(FORM.Email)>
      <cfif Len(Trim(FORM.Email)) LT 1>
         <cfset strError = strError & "Please enter your Email!<br>">
      <cfelse>
         <CFQUERY NAME="GetEmail" DATASOURCE="#datasource#">
           SELECT  Email
           FROM    Table
           WHERE email = <CFQUERYPARAM VALUE="#FORM.EMAIL#" CFSQLTYPE="CF_SQL_VARCHAR">
        </CFQUERY>
        <cfif GetEmail.recordcount GT 0>
            <cfset strError = strError & "That email is already registered <br>to receive the newsletter<br>">
        <cfelse>
           <cfquery  NAME="Added" datasource="#datasource#">
            INSERT INTO Table (Email,firstname, lastname, FUND, GROW)
            VALUES ('#FORM.Email#','#FORM.firstname#','#FORM.lastname#','#FORM.FUND#','#FORM.GROW#')
            </cfquery>
		   <h5>Thank You for Signing up for our Newsletter!</h5>
		   <p>You should start receiving the  Newsletter!soon.</p>
           <!--- 
  		   <cfmail>
             Mail to send
           </cfmail>   --->
           <cfexit> <!-----  STOP PROCESSING, this will keep the form from showing  ------>
		</cfif>
     </cfif>
</cfif>

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

715 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