Solved

Element is undefined in FORM.

Posted on 2004-04-13
5
621 Views
Last Modified: 2013-12-24
Is this wrong?

 <td width="295">
     <input name="tdyTerm" type="radio" value="Yes" <cfif #SESSION.HLS.tdyTerm# EQ form.tdyTerm#>checked</cfif>>
          Yes &nbsp;
     <input name="tdyTerm" type="radio" value="No"<cfif #SESSION.HLS.tdyTerm# EQ #form.tdyTerm#>checked</cfif>>
          No
</td>

I get the error below:
Element TDYTERM is undefined in FORM.

This is what I have at the top of the page:
<CFIF NOT IsDefined("SESSION.HLS")>
    <CFSET SESSION.HLS = StructNew()>
    <CFSET SESSION.HLS.tdyTerm = "">
</CFIF>

<CFIF IsDefined("form.tdyTerm")>
   <CFSET SESSION.HLS.tdyTerm = form.tdyTerm>
   <CFSET SESSION.HLS.project = form.project>
</CFIF>

0
Comment
Question by:Isaac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 10814264
Do you have <form> tags on your page?

Can you show your whole page code?
0
 
LVL 6

Expert Comment

by:reitzen
ID: 10814685
If you are using the FORM scope before the form has been submitted, this is why you are getting this error.

You can try to set a default value to your FORM object:
<cfparam name="FORM.tdyTerm" default="Yes" type="String">

This way, the form object will have a default value at any time and you will not receive the error.
0
 
LVL 5

Author Comment

by:Isaac
ID: 10814824

<!-- Total Number of Steps in the Form. --->
<CFSET NumberOfSteps = 5>
<!-- Session.HLS structure holds user's entries -->
<!-- If structure does not exist, create it. -->
<CFIF NOT IsDefined("SESSION.HLS")>
      <CFSET SESSION.HLS = StructNew()>
      <!-- Represents current page.-->
      <CFSET SESSION.HLS.StepNum = 1>
      
      <!-- Assign user entries to the structure for the first page. -->
      <CFSET SESSION.HLS.fname = "">
      <CFSET SESSION.HLS.lname = "">      
      <CFSET SESSION.HLS.sponDistrict = "">      
      <CFSET SESSION.HLS.City = "">      
      <CFSET SESSION.HLS.State = "">
      <CFSET SESSION.HLS.volWork = "">      
      <CFSET SESSION.HLS.volHome = "">
      <CFSET SESSION.HLS.supName = "">
      <CFSET SESSION.HLS.supWork = "">
      
      <!-- Assign user entries to the structure for the second page. -->
      <CFSET SESSION.HLS.tourdays = "">
      <CFSET SESSION.HLS.visit_dtfr = "">
      <CFSET SESSION.HLS.visit_dtto = "">
      <CFSET SESSION.HLS.deploy = "">
      <CFSET SESSION.HLS.tTime = "">
      
      <!-- Assign user entries to the structure for the third page. -->      
      <CFSET SESSION.HLS.COOPERATIVE = "">
      <CFSET SESSION.HLS.EMPOWERED = "">
      <CFSET SESSION.HLS.PRESENTS = "">
      <CFSET SESSION.HLS.ORGANIZED = "">
      <CFSET SESSION.HLS.COMMITTED = "">
      <CFSET SESSION.HLS.INDUSTRIOUS = "">
      
      <!-- Assign user entries to the structure for the fourth page. -->
      <CFSET SESSION.HLS.FLEXIBLE = "">
      <CFSET SESSION.HLS.COMPETENT = "">
      <CFSET SESSION.HLS.COMMUNICATOR = "">
      <CFSET SESSION.HLS.THINKING = "">
      <CFSET SESSION.HLS.MOTIVATED = "">
      <CFSET SESSION.HLS.NETWORK = "">
      
      <!-- Assign user entries to the structure for the fifth page. -->
      <CFSET SESSION.HLS.tdyTerm = "">
      <CFSET SESSION.HLS.project = "">
      <CFSET SESSION.HLS.cmdr = "">
      <CFSET SESSION.HLS.barriers = "">
      <CFSET SESSION.HLS.expB = ""> 
</CFIF>
      
<!-- If user submitted entries, remember it -->      
<CFIF IsDefined("form.fname")>
      <CFSET SESSION.HLS.fname = "#form.fname#">
      <CFSET SESSION.HLS.lname = "#form.lname#">      
      <CFSET SESSION.HLS.sponDistrict = "#form.sponDistrict#">      
      <CFSET SESSION.HLS.City = "#form.City#">      
      <CFSET SESSION.HLS.State = "#form.State#">
      <CFSET SESSION.HLS.volWork = "#form.volWork#">      
      <CFSET SESSION.HLS.volHome = "#form.volHome#">
      <CFSET SESSION.HLS.supName = "#form.supName#">
      <CFSET SESSION.HLS.supWork = "#form.supWork#">
<CFELSEIF IsDefined("form.tourdays")>
      <CFSET SESSION.HLS.tourdays = form.tourdays>
      <CFSET SESSION.HLS.fromDte = form.visit_dtfr>
      <CFSET SESSION.HLS.toDte = form.visit_dtto>
      <CFSET SESSION.HLS.deploy = form.deploy>
      <CFSET SESSION.HLS.tTime = form.tTime>
<CFELSEIF IsDefined("form.COOPERATIVE")>
      <CFSET SESSION.HLS.cooperative = form.cooperative>
      <CFSET SESSION.HLS.empowered = form.empowered>
      <CFSET SESSION.HLS.presents = form.presents>
      <CFSET SESSION.HLS.organized = form.organized>
      <CFSET SESSION.HLS.committed = form.committed>
      <CFSET SESSION.HLS.industrious = form.industrious>
<CFELSEIF IsDefined("form.flexible")>
      <CFSET SESSION.HLS.flexible = form.flexible>
      <CFSET SESSION.HLS.competent = form.competent>
      <CFSET SESSION.HLS.communicator = form.communicator>
      <CFSET SESSION.HLS.thinking = form.thinking>
      <CFSET SESSION.HLS.motivated = form.motivated>
      <CFSET SESSION.HLS.network = form.network>
<CFELSEIF IsDefined("form.tdyTerm")>
      <CFSET SESSION.HLS.tdyTerm = form.tdyTerm>
      <CFSET SESSION.HLS.project = form.project>
      <CFSET SESSION.HLS.cmdr = form.cmdr>
      <CFSET SESSION.HLS.barriers = form.barriers>
      <CFSET SESSION.HLS.expB = form.expB>
</CFIF>

<!-- If user clicked "Back" button, go back a step -->
<CFIF IsDefined("Form.GoBack")>
      <CFSET SESSION.HLS.StepNum = URL.StepNum - 1>
<!-- If user clicked "Next" button, go forward one -->
<CFELSEIF IsDefined("Form.GoNext")>
      <CFSET SESSION.HLS.StepNum = URL.StepNum + 1>
<!-- If user clicked "Finished" button, we're done -->
<CFELSEIF IsDefined("Form.GoDone")>
      <CFLOCATION URL="specialVol.cfm">
</CFIF>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<CFOUTPUT>
Step #SESSION.HLS.StepNum# of #NumberOfSteps# <a href="logout.cfm">logout</a> </CFOUTPUT>
<!-- Data Entry Form, which submits back to itself -->
<cfform action="specialVol.cfm?StepNum=#SESSION.HLS.StepNum#" method="POST">
    <!-- Display the appropriate step -->        <p>stepnum: </p> <cfoutput>#SESSION.HLS.StepNum#</cfoutput>

    <cfswitch expression="#SESSION.HLS.StepNum#">
      <!-- Step One: Fname -->
<cfcase value="1">
    <table width="721" height="271" border="1">
      <tr>
        <td width="200" height="26">First Name:</td>
        <td width="150"><cfinput name="fname"
                                       size="25"
                                           value="#SESSION.HLS.fname#">
        </td>
        <td width="112">Last Name:</td>
        <td width="239"><cfinput name="lname"
                                       size="25"
                                           value="#SESSION.HLS.lname#">
        </td>
      </tr>
      <tr>
        <td height="26">District: </td>
        <td colspan="3"><cfinput name="sponDistrict"
                                       size="25"
                                           value="#SESSION.HLS.sponDistrict#">
        </td>
      </tr>
      <tr>
        <td height="26">City: </td>
        <td><cfinput name="City"
                                       size="25"
                                           value="#SESSION.HLS.City#">
        </td>
        <td>CMO State </td>
        <td><cfinput name="State"
                                       size="25"
                                           value="#SESSION.HLS.State#">
        </td>
      </tr>
      <tr>
        <td height="23" colspan="4">Contact Phone Numbers </td>
      </tr>
      <tr>
        <td rowspan="2">Volunteer</td>
        <td>Work #: </td>
        <td colspan="2"><cfinput name="volWork"
                                       size="25"
                                           value="#SESSION.HLS.volWork#">
        </td>
      </tr>
      <tr>
        <td height="26">Home #: </td>
        <td colspan="2"><cfinput name="volHome"
                                       size="25"
                                           value="#SESSION.HLS.volHome#">
        </td>
      </tr>
      <tr>
        <td rowspan="2"> Supervisor </td>
        <td>Name:</td>
        <td colspan="2"><cfinput name="supName"
                                       size="25"
                                           value="#SESSION.HLS.supName#">
        </td>
      </tr>
      <tr>
        <td height="26">Work # </td>
        <td colspan="2"><cfinput name="supWork"
                                       size="25"
                                           value="#SESSION.HLS.supWork#">
        </td>
      </tr>
      </table>
</cfcase>
        
<cfcase value="2">
        <table width="817" height="232" border="1">
      <tr>
        <td height="23" colspan="4">Available for, tours of duty</td>
      </tr>
      <tr>
        <td height="42" colspan="4">
                  <select name="tourdays" size="2">
                  <option value="90 days">90 days</option>
                  <option value="179 days">179 days</option>
                  <option value="Long Term">Long Term</option>
                </select>
              </td>
      </tr>
            <tr>
        <td height="23">Have you previously deployed? </td>
        <td colspan="3"><input name="deploy" type="radio" value="Yes">
          Yes &nbsp;
          <input name="deploy" type="radio" value="No">
          No </td>
      </tr>
      <tr>
        <td height="23"><div align="right">Total Time: </div></td>
        <td colspan="3"><cfinput name="tTime"
                                       size="25"
                                           value="#SESSION.HLS.tTime#"></td>
      </tr>
        </table>
</cfcase>

<cfcase value="3">
        <table width="721" border="1">
              <tr>
    <td colspan="2">Areas of Competencies</td>
  </tr>
  <tr>
    <td colspan="2">
        <div>Instructions: Address each area of competency identified below. Type a brief explanation in the space provided to the right (NTE 500 characters) as to how you meet that specific competency.</div>
      </div></td>
    </tr>
  <tr>
    <td width="222">Cooperative</td>
        <td width="483"><textarea name="COOPERATIVE" cols="45" rows="3" id="COOPERATIVE"><cfoutput>#SESSION.HLS.COOPERATIVE#</cfoutput></textarea></td>
  </tr>
  <tr>
    <td>Empowered</td>
    <td><textarea name="EMPOWERED" cols="45" rows="3" id="EMPOWERED"><CFOUTPUT>#SESSION.HLS.EMPOWERED#</CFOUTPUT></textarea></td>
  </tr>
  <tr>
    <td>Presents well to others</td>
    <td><textarea name="PRESENTS" cols="45" rows="3" id="PRESENTS"><CFOUTPUT>#SESSION.HLS.PRESENTS#</CFOUTPUT></textarea></td>
  </tr>
  <tr>
    <td>Organized</td>
    <td><textarea name="ORGANIZED" cols="45" rows="3" id="ORGANIZED"><CFOUTPUT>#SESSION.HLS.ORGANIZED#</CFOUTPUT></textarea></td>
  </tr>
  <tr>
    <td>Committed</td>
    <td><textarea name="COMMITTED" cols="45" rows="3" id="COMMITTED"><CFOUTPUT>#SESSION.HLS.COMMITTED#</CFOUTPUT></textarea></td>
  </tr>
  <tr>
    <td>Industrious</td>
    <td><textarea name="INDUSTRIOUS" cols="45" rows="3" id="INDUSTRIOUS"><CFOUTPUT>#SESSION.HLS.INDUSTRIOUS#</CFOUTPUT></textarea></td>
  </tr>
  </table>
 </cfcase>
 
 <cfcase value="4">
 <table>
  <tr>
    <td>Flexible</td>
    <td><textarea name="FLEXIBLE" cols="45" rows="3" id="FLEXIBLE"><CFOUTPUT>#SESSION.HLS.FLEXIBLE#</CFOUTPUT></textarea></td>
  </tr>
  <tr>
    <td>Competent</td>
    <td><textarea name="COMPETENT" cols="45" rows="3" id="COMPETENT"><CFOUTPUT>#SESSION.HLS.COMPETENT#</CFOUTPUT></textarea></td>
  </tr>
  <tr>
    <td>Good Communicator </td>
    <td><textarea name="COMMUNICATOR" cols="45" rows="3" id="COMMUNICATOR"><CFOUTPUT>#SESSION.HLS.COMMUNICATOR#</CFOUTPUT></textarea></td>
  </tr>
  <tr>
    <td>Out of the box thinking </td>
    <td><textarea name="THINKING" cols="45" rows="3" id="THINKING"><CFOUTPUT>#SESSION.HLS.THINKING#</CFOUTPUT></textarea></td>
  </tr>
  <tr>
    <td>Self-Motivated</td>
    <td><textarea name="MOTIVATED" cols="45" rows="3" id="MOTIVATED"><CFOUTPUT>#SESSION.HLS.MOTIVATED#</CFOUTPUT></textarea></td>
  </tr>
  <tr>
      <td height="72">Knows how to Network </td>
    <td><textarea name="NETWORK" cols="45" rows="3" id="NETWORK"><CFOUTPUT>#SESSION.HLS.NETWORK#</CFOUTPUT></textarea>
      </td>
  </tr>
      </table>
</cfcase>

<CFCASE value="5">
        <table width="721" border="1">
              <tr>
                <td width="410">Are you able to perform short or long term TDY? </td>
                 
        <td width="295">
<input name="tdyTerm" type="radio" value="Yes" <cfif #SESSION.HLS.tdyTerm# EQ #form.tdyTerm#>checked</cfif>>
          Yes &nbsp;
          <input name="tdyTerm" type="radio" value="No"<cfif #SESSION.HLS.tdyTerm# EQ #form.tdyTerm#>checked</cfif>>
No </td>
            </tr>
              <tr>
                <td>Do you expect any challenges if asked to commit to this project? </td>
                <td><input name="project" type="radio" value="Yes">
Yes &nbsp;
<input name="project" type="radio" value="No">
No </td>
            </tr>
              <tr>
                <td>Name of your Cmdr or Director</td>
                <td><cfinput name="cmdr"
                                       size="25"
                                           value="#SESSION.HLS.cmdr#">
              </td>
            </tr>
              <tr>
                <td>You're interested but have barriers - Can we assist you? </td>
              <td><input name="barriers" type="radio" value="Yes">
Yes &nbsp;
<input name="barriers" type="radio" value="No">
No </td>
              </tr>
              <tr>
                <td colspan="2">Explain<br>
              <textarea name="expB" cols="45" rows="3" id="expB"><CFOUTPUT>#SESSION.HLS.expB#</CFOUTPUT></textarea></td>
            </tr>
        </table>
</CFCASE>
</cfswitch>
      
      <p>
      <!--- Show Back button, unless at first step --->
      <CFIF SESSION.HLS.StepNum GT 1>
            <INPUT TYPE="SUBMIT" NAME="GoBack" VALUE="&lt;&lt; Back">
      </CFIF>
      
      <!-- Show next button, unless at last step -->
      <!-- If at last step, show Finish button -->
      <CFIF SESSION.HLS.StepNum LT NumberOfSteps>
            <INPUT TYPE="SUBMIT" NAME="GoNext" VALUE="Next &gt;&gt;">
      <CFELSE>
            <INPUT TYPE="SUBMIT" NAME="GoDone" VALUE="Finish">
      </CFIF>
  </cfform>
 <cfdump var="#SESSION.HLS.tdyTerm#">
  <cfdump var="#form.tdyTerm#">
</body>
</html>
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10815093
Okay the thing is that since the tdyTerm is a radio button and you do not start out with one selected by default - then if the user doesn' select either of the choices then tdyTerm will never be defined in the form.

So you have the following choices :

1) use a cfparam to define a default value as showed by reitzen
2) Start out with one of the radio buttons as selected as a default answer
3) Use a cfif IsDefined("form.tdyTerm") before you access it. (or any other radio button for that matter.
0
 
LVL 35

Accepted Solution

by:
mrichmon earned 500 total points
ID: 10815109
Actually your test to mark it is not correct.

This :
 <input name="tdyTerm" type="radio" value="Yes" <cfif #SESSION.HLS.tdyTerm# EQ form.tdyTerm#>checked</cfif>>

should be this :

 <input name="tdyTerm" type="radio" value="Yes" <cfif #SESSION.HLS.tdyTerm# EQ "Yes">checked</cfif>>

Because since you are assigning SESSION.HLS.tdyTerm to be form.tdyTerm your statement would always be true once you got passed this error.

So if you just change the test you won't have the error AND it will work the way you are expecting.
0

Featured Post

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to Popup 2 97
Re-position sub-options beneath the TAB 7 112
web & database SERVERS -- PHYSICAL & VM ? 5 89
Link failure 16 92
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question