Skip to main content
Participant
April 24, 2011
Question

Help with Undefined Element within a Form

  • April 24, 2011
  • 2 replies
  • 1046 views

Hi.  I am VERY new at this.  I am running ColdFusion 9 using SQL+ for my DB.  I encounter an error that states "Element MOVIE_ID is undefined in FORM.  What am I missing in my FORM?  I'm trying to pull the movie_id for the specific movie that is clicked on in the list results.  Thanks for taking a look!!!!

    <CFQUERY NAME="movie" DATASOURCE="dba192">
       SELECT movie_id, title, category
        FROM movie NATURAL JOIN category

<cfif FORM.title IS NOT "">
WHERE movie.Title LIKE '%#FORM.title#%'
</cfif>

<cfif FORM.category IS NOT "">
WHERE movie.category LIKE '%#FORM.category#%'
</cfif>

        ORDER BY title
    </CFQUERY>

<HTML>
<HEAD>
<TITLE>Movie Mania</TITLE>
<LINK REL=STYLESHEET TYPE="text/css" HREF="../styles.css">
</HEAD>

<BODY>

<cfFORM ACTION="find_detail.cfm" METHOD="post">

<table>
<tr>
<cfoutput>
<th>
<h3>Movie List (#Movie.RecordCount# movies)</h3>
</th>
<th>
<h3>Category</h3>
</th>
</cfoutput>
</tr>
<tr><td colspan="3"><hr /></td></tr>

<cfoutput query="movie">

<tr>
<td>
#CurrentRow#:

<input type="hidden" name="movie_id" value="#movie.movie_id#">

<a href="find_detail.cfm?movie_id=#movie.movie_id#">
#Title#</a>
</td>
<td>
#category#
</td>
</tr>
</cfoutput>
</table>

</cfform>
</body>
</html>

    This topic has been closed for replies.

    2 replies

    Inspiring
    April 25, 2011

    This:

    <a href="find_detail.cfm?movie_id=#movie.movie_id#">#Title#</a>

    Does not submit your form.  It gives you a url variable, not a form variable.  It would seem that the simplest solution is to forget the form and go with a bunch of anchor tags.

    ilssac
    Inspiring
    April 24, 2011

    cynnysue wrote:

    <input type="hidden" name="movie_id" value="#movie.movie_id#">

    <a href="find_detail.cfm?movie_id=#movie.movie_id#">


    You have two different controls here.

    One is a form control.  When this form is submitted, ColdFusion will populated the post data into the Form scope as FORM.MOVIE_ID.

    The second is a link control with an Url paramter.  When this control is clicked, ColdFusion will populate the get data into the Url scope as URL.MOVIE_ID.

    I suspect it is the latter one that is causing your problem.

    cynnysueAuthor
    Participant
    April 24, 2011

    Thank you. Do you know how I can have the URL parameter work properly and "define" movie_id in find_detail.cfm?

    When I remove the form control, I get a message saying the element is undefined in URL. Do you know what I'm missing in order to define it? I think the url is the one i need defined. Once it's defined, how do I reference it in find_detail.cfm? #url.movie_id#?