• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

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

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
alicia1234
Asked:
alicia1234
  • 4
  • 3
3 Solutions
 
bwasyliukCommented:
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
 
Curtis ShullFounderCommented:
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
 
alicia1234Author Commented:
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
bwasyliukCommented:
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
 
alicia1234Author Commented:
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
 
bwasyliukCommented:
I think you want

type="submit"

instead of

type="button"
0
 
alicia1234Author Commented:
THANK YOU, THANK YOU, THANK YOU!!!!!!   ;-)
0
 
alicia1234Author Commented:
Here's another one, if you still want to help!  ;-)

http://www.experts-exchange.com/Web/WebDevSoftware/DreamWeaver/Q_21871919.html
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now