JohnMac328
asked on
CF - trying to hide a form after submit
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
Thanks
ASKER
I changed my logic to <cfif not isdefined(form.butonSubmit name)> 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>
whatever you doing there is happening only when the submit button is clicked so change the condition to this <cfif isdefined("FORM.Submit")>
ASKER
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_SIGN UP\IA_sign up.cfm: line 42
40 : VALUES ('#FORM.Email#','#FORM.fir stname#',' #FORM.last name#','#F ORM.FUND#' ,'#FORM.GR OW#')
41 : </cfquery>
42 : <cfelse>
Context validation error for the cfelse tag.
The tag must be nested inside a CFIF tag.
The error occurred in C:\Inetpub\wwwroot\JQUERY_
40 : VALUES ('#FORM.Email#','#FORM.fir
41 : </cfquery>
42 : <cfelse>
you unclosed <cfif > statement, can you post the entire code
ASKER
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>
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.fir stname#',' #FORM.last name#','#F ORM.FUND#' ,'#FORM.GR OW#')
</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>
<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.fir
</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>
ASKER
It runs but now I am back to trying to get the form to not show after a submit goes through
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' );">
SOme this ng like this
<input type='button' name="btnback" onclick="location.replace(
ASKER
After the form is submitted, I want just the message to show and not the form.
so then what is the question ?
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<cfif not isdefined(form.butonSubmit
then show form
<cfelse>
Message goes here
</cfif>