469,326 Members | 1,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

Error: Element Undefined in Form

53
my code is:

addRecord.cfm

Expand|Select|Wrap|Line Numbers
  1. <cfinclude template="head.cfm">
  2. <p>
  3. <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
  4.   <tr> 
  5.     <td>
  6.     <div align="center"> 
  7.     <P align="left"><strong><font size="+1">Add a New Record </font></strong></P>
  8.               <p align="left">Add your record: </p>
  9.               <form method="post" action="addRecordAction.cfm">
  10. <input type="Hidden" name="Name_Required" Value="You must have a Name!">
  11. <input type="Hidden" name="Address_Required" Value="You must have an Address!">                
  12.  
  13.                 <table width="100%" border="0" cellspacing="0" cellpadding="2">
  14.                   <tr> 
  15.                     <td width="25%"><p><strong>Name:</strong></p></td>
  16.                     <td width="75%"><p> 
  17.                         <input type="text" name="Name" size="40" maxlength="50">
  18.                       </p></td>
  19.                   </tr>
  20.                   <tr> 
  21.                     <td>&nbsp;</td>
  22.                     <td>&nbsp;</td>
  23.                   </tr>
  24.                   <tr> 
  25.                     <td width="25%"><p><strong>Address:</strong></p></td>
  26.                     <td width="75%"><p> 
  27.                         <input type="text" name="Address" size="40" maxlength="50">
  28.                       </p></td>
  29.                   </tr>
  30.                 </table>
  31.                       <BR>
  32.                       <div align="left">
  33.                         <input type="submit" name="SubmitButton" value="Add the Record">
  34.                         <input type="reset" name="ResetButton" value="Reset">
  35.                       </div>
  36.               </form>
  37.             </div>
  38. </td>
  39.         </tr>
  40.       </table>
  41.  
  42. <cfinclude template="foot.cfm">
  43.  

addRecordAction.cfm



Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4.     <title>Add a Record</title>
  5. </head>
  6. <body>
  7.  
  8. <!--- Set the data that is to be updated and the tables they apply to --->
  9.  
  10. <cfquery name="InsertName" datasource="test">
  11.     INSERT
  12.     INTO Name
  13.     (Name)
  14.     VALUES
  15.     ('#Form.Name#') 
  16. </cfquery>
  17.  
  18. <cfquery name="getLastID" datasource="test">
  19.     SELECT MAX(NameID) as LastID
  20.     FROM Name
  21. </cfquery>
  22.  
  23. <cfloop list="#form.Address#" index="FormAddress" delimiters=":">    
  24.  <cfquery name="InsertAddress" datasource="test">
  25.    INSERT INTO Address(NameID, Address)
  26.    VALUES('#getLastID.LastID#','#FormAddress#')
  27.  </cfquery>
  28. </cfloop>
  29.  
  30.  
  31. <cflocation url="addRecord.cfm">
  32. </body>
  33. </html>
  34.  


but i got following error while inserting the record:

Expand|Select|Wrap|Line Numbers
  1. Error Occurred While Processing Request  
  2. Element NAME is undefined in FORM.  
  3.  
  4.  
  5. The error occurred in C:\CFusionMX\wwwroot\jesmi\record\FusionPoll\Admin\polladdaction.cfm: line 15
  6.  
  7. 13 :     (Name)
  8. 14 :     VALUES
  9. 15 :     ('#Form.Name#') 
  10. 16 : </cfquery>
  11. 17 : 
  12.  
  13.  
--------------------------------------------------------------------------------

Expand|Select|Wrap|Line Numbers
  1. Please try the following: 
  2. Check the ColdFusion documentation to verify that you are using the correct syntax. 
  3. Search the Knowledge Base to find a solution to your problem. 
  4.  
  5.  
  6. Browser   Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) 
  7. Remote Address   127.0.0.1 
  8. Referrer    
  9. Date/Time   27-Apr-07 11:52 PM 
  10.  
  11. Stack Trace (click to expand)  
  12. at cfpolladdaction2ecfm1868478318.runPage(C:\CFusionMX\wwwroot\jesmi\record\FusionPoll\Admin\polladdaction.cfm:15) 
  13.  
  14.  
  15. coldfusion.runtime.UndefinedElementException: Element NAME is undefined in FORM.
  16.     at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1049)
  17.     at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1026)
  18.     at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1125)
  19.     at cfpolladdaction2ecfm1868478318.runPage(C:\CFusionMX\wwwroot\jesmi\record\FusionPoll\Admin\polladdaction.cfm:15)
  20.     at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:147)
  21.     at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:357)
  22.     at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:62)
  23.     at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:107)
  24.     at coldfusion.filter.PathFilter.invoke(PathFilter.java:80)
  25.     at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:47)
  26.     at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
  27.     at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:35)
  28.     at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:43)
  29.     at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
  30.     at coldfusion.CfmServlet.service(CfmServlet.java:105)
  31.     at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
  32.     at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
  33.     at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
  34.     at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
  35.     at jrun.servlet.http.WebService.invokeRunnable(WebService.java:168)
  36.     at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:348)
  37.     at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
  38.     at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:294)
  39.     at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
Apr 27 '07 #1
8 13039
acoder
16,027 Expert Mod 8TB
The reason why Name is undefined in Form is that you have defined the input element as "Name_Required" and not "Name".
Apr 27 '07 #2
jesmi
53
my code is:

polladd.cfm:

Expand|Select|Wrap|Line Numbers
  1. <cfinclude template="head.cfm">
  2. <p>
  3. <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
  4.   <tr> 
  5.     <td>
  6.     <div align="center"> 
  7.     <P align="left"><strong><font size="+1">Add a New Record </font></strong></P>
  8.               <p align="left">Add your record: </p>
  9.               <form method="post" action="polladdaction.cfm">
  10. <input type="Hidden" name="Name" Value="You must have a Name!">
  11. <input type="Hidden" name="Address" Value="You must have an Address!">                
  12.  
  13.                 <table width="100%" border="0" cellspacing="0" cellpadding="2">
  14.                   <tr> 
  15.                     <td width="25%"><p><strong>Name:</strong></p></td>
  16.                     <td width="75%"><p> 
  17.                         <input type="text" name="Name" size="40" maxlength="50">
  18.                       </p></td>
  19.                   </tr>
  20.                   <tr> 
  21.                     <td>&nbsp;</td>
  22.                     <td>&nbsp;</td>
  23.                   </tr>
  24.                   <tr> 
  25.                     <td width="25%"><p><strong>Address:</strong></p></td>
  26.                     <td width="75%"><p> 
  27.                         <input type="text" name="Address" size="40" maxlength="50">
  28.                       </p></td>
  29.                   </tr>
  30.                 </table>
  31.                       <BR>
  32.                       <div align="left">
  33.                         <input type="submit" name="SubmitButton" value="Add the Record">
  34.                         <input type="reset" name="ResetButton" value="Reset">
  35.                       </div>
  36.               </form>
  37.             </div>
  38. </td>
  39.         </tr>
  40.       </table>
  41.  
  42. <cfinclude template="foot.cfm">
  43.  
  44.  
  45.  
and another form is:

polladdaction.cfm

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4.     <title>Add a Poll Action Page</title>
  5. </head>
  6. <body>
  7.  
  8. <!--- Set the data that is to be updated and the tables they apply to --->
  9.  
  10. <cfquery name="InsertName" datasource="test">
  11.     INSERT
  12.     INTO Names
  13.     (Name)
  14.     VALUES
  15.     ('#Form.Name#') 
  16. </cfquery>
  17.  
  18. <cfquery name="getLastID" datasource="test">
  19.     SELECT MAX(NameID) as LastID
  20.     FROM Names
  21. </cfquery>
  22.  
  23. <cfloop list="#form.Address#" index="FormAddress" delimiters=":">    
  24.  <cfquery name="InsertAddresses" datasource="test">
  25.    INSERT INTO Addresses(NameID,Address)
  26.    VALUES('#getLastID.LastID#','#FormAddress#')
  27.  </cfquery>
  28. </cfloop>
  29.  
  30.  
  31. <cflocation url="polls.cfm">
  32. </body>
  33. </html>
  34.  
but i got error messages as follows:

Error Occurred While Processing Request
Element NAME is undefined in FORM.


The error occurred in C:\CFusionMX\wwwroot\FusionPoll\Admin\polladdactio n.cfm: line 15

13 : (Name)
14 : VALUES
15 : ('#Form.Name#')
16 : </cfquery>
17 :



--------------------------------------------------------------------------------

Please try the following:
Check the ColdFusion documentation to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.


Browser Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Remote Address 127.0.0.1
Referrer
Date/Time 29-Apr-07 11:25 PM

Expand|Select|Wrap|Line Numbers
  1. Stack Trace (click to expand)  
  2. at cfpolladdaction2ecfm316826830.runPage(C:\CFusionMX\wwwroot\FusionPoll\Admin\polladdaction.cfm:15) 
  3.  
  4.  
  5. coldfusion.runtime.UndefinedElementException: Element NAME is undefined in FORM.
  6.     at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1049)
  7.     at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1026)
  8.     at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1125)
  9.     at cfpolladdaction2ecfm316826830.runPage(C:\CFusionMX\wwwroot\FusionPoll\Admin\polladdaction.cfm:15)
  10.     at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:147)
  11.     at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:357)
  12.     at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:62)
  13.     at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:107)
  14.     at coldfusion.filter.PathFilter.invoke(PathFilter.java:80)
  15.     at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:47)
  16.     at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
  17.     at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:35)
  18.     at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:43)
  19.     at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
  20.     at coldfusion.CfmServlet.service(CfmServlet.java:105)
  21.     at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
  22.     at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
  23.     at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
  24.     at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
  25.     at jrun.servlet.http.WebService.invokeRunnable(WebService.java:168)
  26.     at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:348)
  27.     at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
  28.     at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:294)
  29.     at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
  30.  

what may be the problem please help me!!!
Apr 29 '07 #3
acoder
16,027 Expert Mod 8TB
You've defined Name and Address twice - once as a hidden field and once as a normal text input field.
Apr 30 '07 #4
You've defined Name and Address twice - once as a hidden field and once as a normal text input field.
I get the exact same problem and my code looks like this:
(note: I practically copied the code directly out on an O'reilly book for this)



Expand|Select|Wrap|Line Numbers
  1. <form name="form1" id="form1" method="post" action="course_confirm.cfm">
  2.                   <table width="80%"  border="0" align="center" cellpadding="4" cellspacing="2">
  3.                     <tr>
  4.                       <td colspan="4" align="right">&nbsp;</td>
  5.                       </tr>
  6.                     <tr>
  7.                       <td width="19%" align="right" valign="top"><strong>Course Name: </strong></td>
  8.                       <td colspan="3"><input name="name" type="text" class="formtext" id="name" size="50" /></td>
  9.                     </tr>
  10.                     <tr>
  11.                       <td align="right" valign="top"><strong>Course Category: </strong></td>
  12.                       <td colspan="3"><select name="category" class="formtext" id="category">
  13.                         <option value="No Category Selected" selected="selected">Select a Category</option>
  14.                         <option value="Computing and Information Technology">Computing and Information Technology</option>
  15.                         <option value="Communication Skills">Communication Skills</option>
  16.                         <option value="Project Planning and Research Methodology">Project Planning and Research Methodology</option>
  17.                         <option value="Management Skills">Management Skills</option>
  18.                         <option value="Science Communication">Science Communication</option>
  19.                       </select></td>
  20.                     </tr>
  21.                     <tr>
  22.                       <td align="right" valign="top"><strong>Course Description </strong></td>
  23.                       <td colspan="3"><textarea name="description" cols="75" rows="6" wrap="VIRTUAL" class="formtext" id="description"></textarea></td>
  24.                     </tr>
  25.                     <tr>
  26.                       <td align="right" valign="top"><strong>Prerequisites:</strong></td>
  27.                       <td colspan="3"><textarea name="prerequisites" cols="75" rows="3" wrap="VIRTUAL" class="formtext" id="prerequisites"></textarea></td>
  28.                     </tr>
  29.                     <tr>
  30.                       <td align="right" valign="top"><strong>Who Should Attend: </strong></td>
  31.                       <td colspan="3"><textarea name="attend" cols="75" rows="3" wrap="VIRTUAL" class="formtext" id="attend"></textarea></td>
  32.                     </tr>
  33.                     <tr>
  34.                       <td align="right" valign="top"><strong>Precourse:</strong></td>
  35.                       <td colspan="3"><textarea name="precourse" cols="75" wrap="VIRTUAL" class="formtext" id="precourse"></textarea></td>
  36.                     </tr>
  37.                     <tr>
  38.                       <td align="right"><strong>Tutor 1: </strong></td>
  39.                       <td width="24%"><select name="tutor1" class="formtext" id="tutor1">
  40.                              <option value="No Category Selected" selected="selected">Select a Tutor</option>
  41.                           <cfoutput query="tutors">
  42.                           <option value="#tutors.Tutor_ID#">#tutors.Tutor_Name#</option>
  43.                           </cfoutput>
  44.                       </select></td>
  45.                       <td width="11%" align="right"><strong>Tutor 2: </strong></td>
  46.                       <td width="46%"><select name="tutor2" class="formtext" id="tutor2">
  47.                        <option value="No Category Selected" selected="selected">Select a Tutor</option>
  48.                           <cfoutput query="tutors">
  49.                           <option value="#tutors.Tutor_ID#">#tutors.Tutor_Name#</option>
  50.                           </cfoutput>
  51.                         </select></td>
  52.                     </tr>
  53.                     <tr>
  54.                       <td align="right"><strong>Tutor 3:</strong></td>
  55.                       <td><select name="tutor3" class="formtext" id="tutor3">
  56.                       <option value="No Category Selected" selected="selected">Select a Tutor</option>
  57.                           <cfoutput query="tutors">
  58.                           <option value="#tutors.Tutor_ID#">#tutors.Tutor_Name#</option>
  59.                           </cfoutput>
  60.                       </select></td>
  61.                       <td align="right"><strong>Tutor 4: </strong></td>
  62.                       <td><select name="tutor4" class="formtext" id="tutor4">
  63.                        <option value="No Category Selected" selected="selected">Select a Tutor</option>
  64.                           <cfoutput query="tutors">
  65.                           <option value="#tutors.Tutor_ID#">#tutors.Tutor_Name#</option>
  66.                           </cfoutput>
  67.                       </select></td>
  68.                     </tr>
  69.                     <tr>
  70.                       <td align="right"><br /></td>
  71.                       <td colspan="3"><br />
  72.                         <input name="Submit" type="submit" class="formtext" value="Submit" />
  73.                         <input name="Reset" type="reset" class="formtext" value="Reset" /></td>
  74.                     </tr>
  75.                   </table>
  76.                 </form>
  77.  

and


Expand|Select|Wrap|Line Numbers
  1. <cflock name="insertCourse" type="exclusive" timeout="20">
  2.     <cftransaction>
  3.         <cfquery name="insertNewCourse" datasource="#request.dsn#">
  4.             INSERT INTO Courses (Course_Name, course_category, course_description, prerequisites,
  5.                                 who_attend, Precourse)
  6.             VALUES ('#form1.name#', '#form1.category#', '#form1.description#', '#form1.prerequisites#',
  7.                     '#form1.attend#', '#form1.precourse#')
  8.         </cfquery>
  9.         <cfquery name="getKey" datasource="#request.dsn#">
  10.             SELECT Max(Course_ID) AS MaxID
  11.             FROM Courses
  12.         </cfquery>
  13.     </cftransaction>
  14. </cflock>
  15.  
  16. <cflock name="inserttutorassoc" type="exclusive" timeout="20">
  17.     <cftransaction>
  18.         <cfif #from1.tutor1# is not "No Category Selected">
  19.             <cfquery name="tutor1" datasource="#request.dsn#">
  20.                 INSERT INTO Tutorlist(fk_course_id, fk_tutor_id)
  21.                 VALUES(#getKey.MaxID#,#form1.tutor1#)
  22.             </cfquery>            
  23.         </cfif>
  24.         <cfif #from1.tutor2# is not "No Category Selected">
  25.             <cfquery name="tutor2" datasource="#request.dsn#">
  26.                 INSERT INTO Tutorlist(fk_course_id, fk_tutor_id)
  27.                 VALUES(#getKey.MaxID#,#form1.tutor2#)
  28.             </cfquery>            
  29.         </cfif>
  30.         <cfif #from1.tutor3# is not "No Category Selected">
  31.             <cfquery name="tutor3" datasource="#request.dsn#">
  32.                 INSERT INTO Tutorlist(fk_course_id, fk_tutor_id)
  33.                 VALUES(#getKey.MaxID#, #form1.tutor3#)
  34.             </cfquery>            
  35.         </cfif>
  36.         <cfif #from1.tutor4# is not "No Category Selected">
  37.             <cfquery name="tutor4" datasource="#request.dsn#">
  38.                 INSERT INTO Tutorlist(fk_course_id, fk_tutor_id)
  39.                 VALUES(#getKey.MaxID#, #form1.tutor4#)
  40.             </cfquery>            
  41.         </cfif>
  42.     </cftransaction>
  43. </cflock>


I'd also be very curious to fond out what could possibly be wrong here ...
Thanks in advance
Jun 12 '07 #5
acoder
16,027 Expert Mod 8TB
Use #form...# instead of #form1...#
Jun 12 '07 #6
Use #form...# instead of #form1...#

thanks, I will give that a shot
Jun 13 '07 #7
Use #form...# instead of #form1...#

that worked a treat! Thanks :)
Jun 13 '07 #8
acoder
16,027 Expert Mod 8TB
that worked a treat! Thanks :)
No problem, you're welcome. Post again if you have any more questions.
Jun 13 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Wm | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.