Sunday, August 29, 2004

Coldfusion: answering form input

Oftentimes, I put an if statement on a page to look for a form variable to be returned so that the page knows to do something if a form is being submitted, like this:
< ifdefined('form.submit')>

However, if you change the name of that form field, then this if statement gets messed up. My new way of detecting if a form has been submitted is to see if the form structure is not empty. There is always a form structure (or scope), however, if it is empty, then no form has been submitted:
<cfif not StructIsEmpty(form)>

I did this because I am working on a widget that will display a number of choices and allow the user to add an answer to the list, like this:


No comments:

Post a Comment