?
Solved

Why am I getting an "Element is undefined in FORM" error?

Posted on 2006-06-01
8
Medium Priority
?
289 Views
Last Modified: 2010-04-25
Why does the following code not work? I'm using Dreamweaver. When I hit F12 to test my page, I get this error:
"Element RecipeID is undefined in FORM"
The error points to the line that begins with "action=" ...
It's a simple form: it has one field, "RecipeID" and a button. The user is supposed to fill in the RecipeID field with a number and then hit the "Delete" button.
I isolated the code to a brand new page (contains ONLY the code shown below) and I still get the error).
I know it's probably some dumb mistake but I just can't see it and it's driving me CRAZY!!!!

<form id="formDelete" name="formDelete" method="post"
        action="deleterecipe.cfm?recID=<cfoutput>#FORM.RecipeID#</cfoutput>" target="_blank">
      <table width="250" border="0" cellspacing="0" cellpadding="0">
       <tr>
          <td>DELETE A RECIPE</td>
        </tr>
        <tr>
          <td>Recipe ID
          <input name="RecipeID" type="text" id="RecipeID" size="10" />
          </td>
        </tr>
        <tr>
      <td>
        <input name="Submit2" type="button" class="darkbutton" value="Delete" />
        </td>
         </tr>
      </table>
  </form>
0
Comment
Question by:alicia1234
  • 4
  • 3
8 Comments
 
LVL 7

Assisted Solution

by:bwasyliuk
bwasyliuk earned 1000 total points
ID: 16812056
If the above code is the ONLY code on the page, then FORM.RecipeID is not defined until you post the form back to itself.

Now, from your code above, why are you asking the user to enter a RecipeID and also trying to put a RecipeID in the Action parameter?
0
 
LVL 3

Expert Comment

by:Onyx23
ID: 16812057
Cold Fusion seems to have a hard time finding your variable - hence why you r getting the  error. From the information given and from the error I can assume that ColdFusion was looking for 'RecipeID' in the form scope, but the variable definition doesn't appear in the code.

You can avoid this situation by providing a default value with the cfparam tag or we can use an isdefined function to hide the variable on the initial page load. Place in the top ofyour page.

<cfparam name="form.RecipeID" default="1">


This provides default value for your form variable so Cold Fusion can see it.
Hope this helps
0
 

Author Comment

by:alicia1234
ID: 16812120
bwyasliuk:
>>>> Now, from your code above, why are you asking the user to enter a RecipeID and also trying to put a RecipeID in the Action parameter?

Because I want to enter the RecipeID, and then pass that parameter to another page. The other page is the action of the form.
So, for example,
Enter RecipeID equal to 5. Click "Delete".

my action is:
action="deleterecipe.cfm?recID=<cfoutput>#FORM.RecipeID#</cfoutput>"

That way I can get to another page and add in the recipe name and be sure that I really want to delete it.

If there is a more "elegant" way, please let me know!
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
LVL 7

Accepted Solution

by:
bwasyliuk earned 1000 total points
ID: 16812151
I think you are ahead of the game a bit by puting

action="deleterecipe.cfm?recID=<cfoutput>#FORM.RecipeID#</cfoutput>"

Since in the above form code your are promting the user for the RecipeID that they want to delete - your server doesnt know what the #form.RecipeID# is yet - because the user hasnt submitted the form.

When you have the form like the following:

<form id="formDelete" name="formDelete" method="post"
       action="deleterecipe.cfm" target="_blank">
      <table width="250" border="0" cellspacing="0" cellpadding="0">
       <tr>
          <td>DELETE A RECIPE</td>
        </tr>
        <tr>
          <td>Recipe ID
          <input name="RecipeID" type="text" id="RecipeID" size="10" />
          </td>
        </tr>
        <tr>
     <td>
       <input name="Submit2" type="button" class="darkbutton" value="Delete" />
       </td>
         </tr>
      </table>
  </form>


in the deleterecipe.cfm page you will be able to use the #form.RecipeID# variable to reference the data that the user entered.

Am I on track with what you want to do?
0
 

Author Comment

by:alicia1234
ID: 16812290
yes you are definitely on track.

I changed my action to be as you said ...
action="deleterecipe.cfm"
(and then use FORM.RecipeID in my delete page)

but when I click on my Delete button, nothing happens!
0
 
LVL 7

Assisted Solution

by:bwasyliuk
bwasyliuk earned 1000 total points
ID: 16812301
I think you want

type="submit"

instead of

type="button"
0
 

Author Comment

by:alicia1234
ID: 16812318
THANK YOU, THANK YOU, THANK YOU!!!!!!   ;-)
0
 

Author Comment

by:alicia1234
ID: 16812374
Here's another one, if you still want to help!  ;-)

http://www.experts-exchange.com/Web/WebDevSoftware/DreamWeaver/Q_21871919.html
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline
Suggested Courses

850 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