Error: Element Undefined in Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jesmi
    New Member
    • Apr 2007
    • 53

    Error: Element Undefined in Form

    my code is:

    addRecord.cfm

    Code:
    <cfinclude template="head.cfm">
    <p>
    <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
      <tr> 
        <td>
    	<div align="center"> 
        <P align="left"><strong><font size="+1">Add a New Record </font></strong></P>
                  <p align="left">Add your record: </p>
                  <form method="post" action="addRecordAction.cfm">
    <input type="Hidden" name="Name_Required" Value="You must have a Name!">
    <input type="Hidden" name="Address_Required" Value="You must have an Address!">                
                          
                    <table width="100%" border="0" cellspacing="0" cellpadding="2">
                      <tr> 
                        <td width="25%"><p><strong>Name:</strong></p></td>
                        <td width="75%"><p> 
                            <input type="text" name="Name" size="40" maxlength="50">
                          </p></td>
                      </tr>
                      <tr> 
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr> 
                        <td width="25%"><p><strong>Address:</strong></p></td>
                        <td width="75%"><p> 
                            <input type="text" name="Address" size="40" maxlength="50">
                          </p></td>
                      </tr>
                    </table>
                          <BR>
    				      <div align="left">
                            <input type="submit" name="SubmitButton" value="Add the Record">
                            <input type="reset" name="ResetButton" value="Reset">
                          </div>
                  </form>
                </div>
    </td>
            </tr>
          </table>
    	  
    <cfinclude template="foot.cfm">

    addRecordAction .cfm



    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    	<title>Add a Record</title>
    </head>
    <body>
    
    <!--- Set the data that is to be updated and the tables they apply to --->
    
    <cfquery name="InsertName" datasource="test">
    	INSERT
    	INTO Name
    	(Name)
    	VALUES
    	('#Form.Name#') 
    </cfquery>
    
    <cfquery name="getLastID" datasource="test">
    	SELECT MAX(NameID) as LastID
    	FROM Name
    </cfquery>
    
    <cfloop list="#form.Address#" index="FormAddress" delimiters=":">	
     <cfquery name="InsertAddress" datasource="test">
       INSERT INTO Address(NameID, Address)
       VALUES('#getLastID.LastID#','#FormAddress#')
     </cfquery>
    </cfloop>
    	
    
    <cflocation url="addRecord.cfm">
    </body>
    </html>


    but i got following error while inserting the record:

    Code:
    Error Occurred While Processing Request  
    Element NAME is undefined in FORM.  
     
      
    The error occurred in C:\CFusionMX\wwwroot\jesmi\record\FusionPoll\Admin\polladdaction.cfm: line 15
     
    13 : 	(Name)
    14 : 	VALUES
    15 : 	('#Form.Name#') 
    16 : </cfquery>
    17 :
    --------------------------------------------------------------------------------

    Code:
    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   27-Apr-07 11:52 PM 
     
    Stack Trace (click to expand)  
    at cfpolladdaction2ecfm1868478318.runPage(C:\CFusionMX\wwwroot\jesmi\record\FusionPoll\Admin\polladdaction.cfm:15) 
    
    
    coldfusion.runtime.UndefinedElementException: Element NAME is undefined in FORM.
    	at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1049)
    	at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1026)
    	at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1125)
    	at cfpolladdaction2ecfm1868478318.runPage(C:\CFusionMX\wwwroot\jesmi\record\FusionPoll\Admin\polladdaction.cfm:15)
    	at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:147)
    	at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:357)
    	at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:62)
    	at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:107)
    	at coldfusion.filter.PathFilter.invoke(PathFilter.java:80)
    	at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:47)
    	at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
    	at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:35)
    	at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:43)
    	at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
    	at coldfusion.CfmServlet.service(CfmServlet.java:105)
    	at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
    	at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    	at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
    	at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
    	at jrun.servlet.http.WebService.invokeRunnable(WebService.java:168)
    	at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:348)
    	at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
    	at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:294)
    	at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
    Last edited by acoder; Apr 2 '12, 12:20 PM.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The reason why Name is undefined in Form is that you have defined the input element as "Name_Requi red" and not "Name".

    Comment

    • jesmi
      New Member
      • Apr 2007
      • 53

      #3
      i again got problem

      my code is:

      polladd.cfm:

      Code:
      <cfinclude template="head.cfm">
      <p>
      <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
        <tr> 
          <td>
      	<div align="center"> 
          <P align="left"><strong><font size="+1">Add a New Record </font></strong></P>
                    <p align="left">Add your record: </p>
                    <form method="post" action="polladdaction.cfm">
      <input type="Hidden" name="Name" Value="You must have a Name!">
      <input type="Hidden" name="Address" Value="You must have an Address!">                
                            
                      <table width="100%" border="0" cellspacing="0" cellpadding="2">
                        <tr> 
                          <td width="25%"><p><strong>Name:</strong></p></td>
                          <td width="75%"><p> 
                              <input type="text" name="Name" size="40" maxlength="50">
                            </p></td>
                        </tr>
                        <tr> 
                          <td>&nbsp;</td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr> 
                          <td width="25%"><p><strong>Address:</strong></p></td>
                          <td width="75%"><p> 
                              <input type="text" name="Address" size="40" maxlength="50">
                            </p></td>
                        </tr>
                      </table>
                            <BR>
      				      <div align="left">
                              <input type="submit" name="SubmitButton" value="Add the Record">
                              <input type="reset" name="ResetButton" value="Reset">
                            </div>
                    </form>
                  </div>
      </td>
              </tr>
            </table>
      	  
      <cfinclude template="foot.cfm">
      and another form is:

      polladdaction.c fm

      Code:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html>
      <head>
      	<title>Add a Poll Action Page</title>
      </head>
      <body>
      
      <!--- Set the data that is to be updated and the tables they apply to --->
      
      <cfquery name="InsertName" datasource="test">
      	INSERT
      	INTO Names
      	(Name)
      	VALUES
      	('#Form.Name#') 
      </cfquery>
      
      <cfquery name="getLastID" datasource="test">
      	SELECT MAX(NameID) as LastID
      	FROM Names
      </cfquery>
      
      <cfloop list="#form.Address#" index="FormAddress" delimiters=":">	
       <cfquery name="InsertAddresses" datasource="test">
         INSERT INTO Addresses(NameID,Address)
         VALUES('#getLastID.LastID#','#FormAddress#')
       </cfquery>
      </cfloop>
      	
      
      <cflocation url="polls.cfm">
      </body>
      </html>
      but i got error messages as follows:

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


      The error occurred in C:\CFusionMX\ww wroot\FusionPol l\Admin\polladd action.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

      Code:
      Stack Trace (click to expand)  
      at cfpolladdaction2ecfm316826830.runPage(C:\CFusionMX\wwwroot\FusionPoll\Admin\polladdaction.cfm:15) 
      
      
      coldfusion.runtime.UndefinedElementException: Element NAME is undefined in FORM.
      	at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1049)
      	at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1026)
      	at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1125)
      	at cfpolladdaction2ecfm316826830.runPage(C:\CFusionMX\wwwroot\FusionPoll\Admin\polladdaction.cfm:15)
      	at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:147)
      	at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:357)
      	at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:62)
      	at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:107)
      	at coldfusion.filter.PathFilter.invoke(PathFilter.java:80)
      	at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:47)
      	at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
      	at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:35)
      	at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:43)
      	at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
      	at coldfusion.CfmServlet.service(CfmServlet.java:105)
      	at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
      	at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
      	at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:252)
      	at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
      	at jrun.servlet.http.WebService.invokeRunnable(WebService.java:168)
      	at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:348)
      	at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
      	at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:294)
      	at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

      what may be the problem please help me!!!
      Last edited by acoder; Apr 2 '12, 12:22 PM.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You've defined Name and Address twice - once as a hidden field and once as a normal text input field.

        Comment

        • badalki
          New Member
          • Jun 2007
          • 3

          #5
          Originally posted by acoder
          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)



          Code:
          <form name="form1" id="form1" method="post" action="course_confirm.cfm">
                            <table width="80%"  border="0" align="center" cellpadding="4" cellspacing="2">
                              <tr>
                                <td colspan="4" align="right">&nbsp;</td>
                                </tr>
                              <tr>
                                <td width="19%" align="right" valign="top"><strong>Course Name: </strong></td>
                                <td colspan="3"><input name="name" type="text" class="formtext" id="name" size="50" /></td>
                              </tr>
                              <tr>
                                <td align="right" valign="top"><strong>Course Category: </strong></td>
                                <td colspan="3"><select name="category" class="formtext" id="category">
                                  <option value="No Category Selected" selected="selected">Select a Category</option>
                                  <option value="Computing and Information Technology">Computing and Information Technology</option>
                                  <option value="Communication Skills">Communication Skills</option>
                                  <option value="Project Planning and Research Methodology">Project Planning and Research Methodology</option>
                                  <option value="Management Skills">Management Skills</option>
                                  <option value="Science Communication">Science Communication</option>
                                </select></td>
                              </tr>
                              <tr>
                                <td align="right" valign="top"><strong>Course Description </strong></td>
                                <td colspan="3"><textarea name="description" cols="75" rows="6" wrap="VIRTUAL" class="formtext" id="description"></textarea></td>
                              </tr>
                              <tr>
                                <td align="right" valign="top"><strong>Prerequisites:</strong></td>
                                <td colspan="3"><textarea name="prerequisites" cols="75" rows="3" wrap="VIRTUAL" class="formtext" id="prerequisites"></textarea></td>
                              </tr>
                              <tr>
                                <td align="right" valign="top"><strong>Who Should Attend: </strong></td>
                                <td colspan="3"><textarea name="attend" cols="75" rows="3" wrap="VIRTUAL" class="formtext" id="attend"></textarea></td>
                              </tr>
                              <tr>
                                <td align="right" valign="top"><strong>Precourse:</strong></td>
                                <td colspan="3"><textarea name="precourse" cols="75" wrap="VIRTUAL" class="formtext" id="precourse"></textarea></td>
                              </tr>
                              <tr>
                                <td align="right"><strong>Tutor 1: </strong></td>
                                <td width="24%"><select name="tutor1" class="formtext" id="tutor1">
          							 <option value="No Category Selected" selected="selected">Select a Tutor</option>
          					      <cfoutput query="tutors">
          						  <option value="#tutors.Tutor_ID#">#tutors.Tutor_Name#</option>
          						  </cfoutput>
                                </select></td>
                                <td width="11%" align="right"><strong>Tutor 2: </strong></td>
                                <td width="46%"><select name="tutor2" class="formtext" id="tutor2">
          					   <option value="No Category Selected" selected="selected">Select a Tutor</option>
          					      <cfoutput query="tutors">
          						  <option value="#tutors.Tutor_ID#">#tutors.Tutor_Name#</option>
          						  </cfoutput>
                                  </select></td>
                              </tr>
                              <tr>
                                <td align="right"><strong>Tutor 3:</strong></td>
                                <td><select name="tutor3" class="formtext" id="tutor3">
          					  <option value="No Category Selected" selected="selected">Select a Tutor</option>
          					      <cfoutput query="tutors">
          						  <option value="#tutors.Tutor_ID#">#tutors.Tutor_Name#</option>
          						  </cfoutput>
                                </select></td>
                                <td align="right"><strong>Tutor 4: </strong></td>
                                <td><select name="tutor4" class="formtext" id="tutor4">
          					   <option value="No Category Selected" selected="selected">Select a Tutor</option>
          					      <cfoutput query="tutors">
          						  <option value="#tutors.Tutor_ID#">#tutors.Tutor_Name#</option>
          						  </cfoutput>
                                </select></td>
                              </tr>
                              <tr>
                                <td align="right"><br /></td>
                                <td colspan="3"><br />
                                  <input name="Submit" type="submit" class="formtext" value="Submit" />
                                  <input name="Reset" type="reset" class="formtext" value="Reset" /></td>
                              </tr>
                            </table>
                          </form>

          and


          Code:
          <cflock name="insertCourse" type="exclusive" timeout="20">
          	<cftransaction>
          		<cfquery name="insertNewCourse" datasource="#request.dsn#">
          			INSERT INTO Courses (Course_Name, course_category, course_description, prerequisites,
          								who_attend, Precourse)
          			VALUES ('#form1.name#', '#form1.category#', '#form1.description#', '#form1.prerequisites#',
          					'#form1.attend#', '#form1.precourse#')
          		</cfquery>
          		<cfquery name="getKey" datasource="#request.dsn#">
          			SELECT Max(Course_ID) AS MaxID
          			FROM Courses
          		</cfquery>
          	</cftransaction>
          </cflock>
          
          <cflock name="inserttutorassoc" type="exclusive" timeout="20">
          	<cftransaction>
          		<cfif #from1.tutor1# is not "No Category Selected">
          			<cfquery name="tutor1" datasource="#request.dsn#">
          				INSERT INTO Tutorlist(fk_course_id, fk_tutor_id)
          				VALUES(#getKey.MaxID#,#form1.tutor1#)
          			</cfquery>			
          		</cfif>
          		<cfif #from1.tutor2# is not "No Category Selected">
          			<cfquery name="tutor2" datasource="#request.dsn#">
          				INSERT INTO Tutorlist(fk_course_id, fk_tutor_id)
          				VALUES(#getKey.MaxID#,#form1.tutor2#)
          			</cfquery>			
          		</cfif>
          		<cfif #from1.tutor3# is not "No Category Selected">
          			<cfquery name="tutor3" datasource="#request.dsn#">
          				INSERT INTO Tutorlist(fk_course_id, fk_tutor_id)
          				VALUES(#getKey.MaxID#, #form1.tutor3#)
          			</cfquery>			
          		</cfif>
          		<cfif #from1.tutor4# is not "No Category Selected">
          			<cfquery name="tutor4" datasource="#request.dsn#">
          				INSERT INTO Tutorlist(fk_course_id, fk_tutor_id)
          				VALUES(#getKey.MaxID#, #form1.tutor4#)
          			</cfquery>			
          		</cfif>
          	</cftransaction>
          </cflock>


          I'd also be very curious to fond out what could possibly be wrong here ...
          Thanks in advance
          Last edited by acoder; Apr 2 '12, 12:23 PM.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Use #form...# instead of #form1...#

            Comment

            • badalki
              New Member
              • Jun 2007
              • 3

              #7
              Originally posted by acoder
              Use #form...# instead of #form1...#

              thanks, I will give that a shot

              Comment

              • badalki
                New Member
                • Jun 2007
                • 3

                #8
                Originally posted by acoder
                Use #form...# instead of #form1...#

                that worked a treat! Thanks :)

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Originally posted by badalki
                  that worked a treat! Thanks :)
                  No problem, you're welcome. Post again if you have any more questions.

                  Comment

                  Working...