Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Element Undefined in Form

New Here ,
May 08, 2007 May 08, 2007
Hello:

I have approximately 1000 people per day who fill out our form on the web. probably 20 or 30 times per day, I get an "element lname undefined in form" message. (a try-catch sends me an email about the prob). I have searched the web thoroughly, and it is not a improper naming of the form element or doubling up on form elements issue.

What is happening is that the user fills out their zipcode, a little processing goes on and some session variables are set. The user arrives at a more detailed form. When they fill out the form and press submit, it goes to a processing page and quickly throws the error.

Any ideas?
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 08, 2007 May 08, 2007
Can you show the code? It seems that the form variable isn't being set and when it submits, it's undefined. If it's not a required field, you should add a check to see if it is defined (i.e. isDefined("Form.variablename")) or set a cfparam to the form variable.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 09, 2007 May 09, 2007
there are several hundred lines of code but i took out some lines that should be enough to give the idea. remember what is strange is that maybe 5% of the time when the post gets over to appProc.cfm, the whole form structure is empty. (Know this from wrapping try/catch around the first processing statement using a form var, sending me an email with a dump of "form") some of the appProc.cfm code is below the first code:

<cfparam name="local_fname" default="">
<cfparam name="local_lname" default="">
<cfif isDefined('url.hasError')>
<cfset focusThis=url.hasError>
<cfset local_fname=url.fname>
<cfset local_lname=url.lname>
</cfif>

<form name="contactInfo" method="post" action="appProc.cfm">
<cfoutput>First<input type="text" maxlength="20" name="fname" class="cfname" value="#local_fname#"<cfif hasError EQ "fname"> style="border-color: ##ff0000;border-style:solid;"</cfif>/></cfoutput>
<cfoutput>Last <input type="text" maxlength="30" name="lname" class="clname" value="#local_lname#"<cfif hasError EQ "lname"> style="border-color: ##ff0000;border-style:solid;"</cfif>/></cfoutput>
<input class="submit" name="Submit" type="submit" value="Get Quote!"></td>
</form>

some of the code from appProc.cfm:

<cftry>
<cfif form.fname EQ "">
<cfset errorMessage = "Sorry! Please enter your first and last name.">
<cfset hasError = "fname">
<cflocation url="app.cfm?hasError=#hasError#&email=#form.email#&zip_code=#form.zipcode#&fname=#form.fname#&lname=#form.lname#&address=#address#&city=#form.city#&state=#form.state#&hphone=#form.hphone#&wphone=#form.wphone#&wphonex=#form.wphonex#&curIns=#form.curIns#&curPremium=#form.curPremium#&a1birthMonth=#form.a1birthMonth#&a1birthDay=#form.a1birthDay#&a1birthYear=#form.a1birthYear#&a1gender=#form.a1gender#&a1heightFt=#form.a1heightFt#&a1heightIn=#form.a1heightIn#&a1weight=#form.a1weight#&a1smoker=#form.a1smoker#&a2birthMonth=#form.a2birthMonth#&a2birthDay=#form.a2birthDay#&a2birthYear=#form.a2birthYear#&a2gender=#form.a2gender#&a2heightFt=#form.a2heightFt#&a2heightIn=#form.a2heightIn#&a2weight=#form.a2weight#&a2smoker=#form.a2smoker#&q12months=#form.q12months#&visibility=#form.isvis#&errorMessage=#errorMessage#" addToken="yes">
<cfelse>
<cfinvoke component="validator" method="dataScrubber" returnvariable="form.fname">
<cfinvokeargument name="field_data" value="#form.fname#">
<cfinvokeargument name="scrub" value="name">
</cfinvoke>
<cfinvoke component="validator" method="validator" returnvariable="isvalid">
<cfinvokeargument name="field_data" value="#form.fname#">
<cfinvokeargument name="fieldtype" value="text">
</cfinvoke>
<cfif isvalid EQ 'FALSE'>
<cfset errorMessage = "Sorry! Please enter a valid first and last name.">
<cfset hasError = "fname">
<cflocation url="app.cfm?hasError=#hasError#&email=#form.email#&zip_code=#form.zipcode#&fname=#form.fname#&lname=#form.lname#&address=#address#&city=#form.city#&state=#form.state#&hphone=#form.hphone#&wphone=#form.wphone#&wphonex=#form.wphonex#&curIns=#form.curIns#&curPremium=#form.curPremium#&a1birthMonth=#form.a1birthMonth#&a1birthDay=#form.a1birthDay#&a1birthYear=#form.a1birthYear#&a1gender=#form.a1gender#&a1heightFt=#form.a1heightFt#&a1heightIn=#form.a1heightIn#&a1weight=#form.a1weight#&a1smoker=#form.a1smoker#&a2birthMonth=#form.a2birthMonth#&a2birthDay=#form.a2birthDay#&a2birthYear=#form.a2birthYear#&a2gender=#form.a2gender#&a2heightFt=#form.a2heightFt#&a2heightIn=#form.a2heightIn#&a2weight=#form.a2weight#&a2smoker=#form.a2smoker#&q12months=#form.q12months#&visibility=#form.isvis#&errorMessage=#errorMessage#" addToken="yes">
</cfif>
</cfif>
<cfcatch type="any">
<cfmail to=""
from=#Application.emailSystem#
server=#Application.emailServer#
username=#Application.emailUserName#
password=#Application.emailPwd#
spoolenable="yes"
subject="Form.fname undefined error analysis">
<cfmailpart type="html">
<cfif Isdefined('cfcatch.message')>Message:#cfcatch.message#</cfif>
<cfif Isdefined('cfcatch.Detail')>Detail:#cfcatch.Detail#</cfif>
<cfif Isdefined('cfcatch.Type')>Type:#cfcatch.Type#</cfif>
<cfif Isdefined('cfcatch.ErrNumber')>#cfcatch.ErrNumber#</cfif>
<cfdump var="#session#"><br />
<cfdump var="#FORM#"><br />
<cfdump var="#CGI#"><br />
<cfdump var="#URL#"><br />
</cfmailpart>
</cfmail>
</cfcatch>
</cftry>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 09, 2007 May 09, 2007
When you submit, can you just do a plain <cfdump var="#Form#"> and see what it spits out - before you do any processing?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 11, 2007 May 11, 2007
The problem with that is that the problem is intermittent. It only happens maybe 2% of the time, so If I dump variables they will more than likely show up fine. The try/catch above catches it if form.fname is missing, and sends a dump of #form#. The entire form structure is always empty.

Let me know if you have any other thoughts...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 11, 2007 May 11, 2007
What happens at the end of appProc.cfm? If it doesnt do a <cflocation> to somewhere else and someone refreshes their browser....
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 11, 2007 May 11, 2007
LATEST
Look through your CF log files for the undefined message your seeing, you may possibly see something related to why it's happening at that specific time/user/machine. It's a long shot but I've had a lot of luck going through log files in the past.

<cftry>
<cfif form.fname EQ "">
<cfset errorMessage = "Sorry! Please enter your first and last name.">
<cfset hasError = "fname">
<cflocation url="app.cfm?....

You can probably remove some the code in your action page by checking if the form fields are entered before submitting. Just look at <cfform> and <cfinput message="" required="">. Maybe you could remove the intermittent error that way.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources