Link to home
Start Free TrialLog in
Avatar of JohnMac328
JohnMac328Flag for United States of America

asked on

CF - Undefined form element

I can't see why the element GROW which is a form field is undefined when I am defining it with the EMAIL form field and it does not error out on EMAIL.

Any help is appreciated
<cfparam name="FORM.Email" default="">
<cfparam name="FORM.GROW" default="N">
<!--- Create an empty error string --->
<cfset strError = "">

<!--- If the form is submitted --->
<cfif isDefined("FORM.Submit")>
   <cfparam name="FORM.Email" default="">
   <cfparam name="FORM.GROW" default="N">
<!---    <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="HotBanana">
           SELECT  Email, GROW
           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="HotBanana">
            INSERT INTO table (Email,GROW)
            VALUES ('#FORM.Email#','#FORM.GROW#')
            </cfquery>
           <cfset strError = "Added to the newsletter<br>">  
<body>
<p><cfform action="data_entry_form.cfm" method="post"> 
		<table width="400" border="0" cellspacing="0" cellpadding="3"> 
			<!--- Add table row to show error message ---> 
			<tr> 
				<td colspan="2"><cfif len(strError)>
  <div style="position:relative;left:5px; top:2px;padding:10px; background-color:#FFFFFF;width:250px;color:maroon;text-align:right;">
 <cfoutput>#strError#</cfoutput>
 </div>
</cfif></td> 
		  </tr> 
           	   
            <tr> 
				<td><h2 class="style1">Email:</h2></td> 
				<td> 
					<!--- Email textfield - REQUIRED ---> 
					<cfinput 
					type="text" 
					name="Email" 
					size="30"></td> 
			<td><h2 class="style1">GROW:</h2></td> 
            <td>
			 <cfselect name="GROW">
          <option value='Y' <cfif GetEmail.GROW EQ 'Y'>selected="selected"</cfif> >Yes</option>
          <option value='N' <cfif GetEmail.GROW NEQ 'Y'>selected="selected"</cfif> >No</option>
             </cfselect>
          
</td>

Open in new window

Avatar of JohnMac328
JohnMac328
Flag of United States of America image

ASKER

It starts to bomb on line 56
ASKER CERTIFIED SOLUTION
Avatar of duncancumming
duncancumming
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Pravin Asar

Looks like you are on your way to solution.

In future to debug similar issues you may

<cfoutput>#form.fieldnames#</cfoutput>

or

<cfdump var="#form#">

No points please.
Great thanks