EasyCFM.COM ColdFusion Forums / Coding Help! / basic form

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: basic form

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

johnbarrett
10-22-2012 @ 7:53 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Member
Posts:
Joined: Oct 2012

I am trying to build a basic one field form, and the action page shows the
email you entered.

<!---form page--->
<form id="newsletter-form" action="newsletter.cfm">
  <input type="text" name="newsletter-text-input" id="newsletter-text-  
input"  value="" placeholder="your email..." />
  <input type="submit" name="newsletter" value="Submit"/>
</form>

<!--- action page--->
<cfoutput>
#FORM.newsletter-text-input#
</cfoutput>

the error I get is:
"Element NEWSLETTER is undefined in FORM."

Any help would be great

thank you,
Johnny

Thanks,
Johnny

nmiller
10-22-2012 @ 8:07 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 773
Joined: Apr 2003

if you don't provide a method attribute in a form, the
default will be 'get', which will put form variables into
the URL scope.  On the action page, either refer to
URL.newsletter-text-input or change your form tag and add

method="post"

Nathan Miller
NM Consulting

cfSearchin
11-07-2012 @ 1:23 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 608
Joined: Feb 2008

Also you cannot use dot notation with that field name. When the name contains invalid characters ie "-" you need to use associative array notation to access the value:


<cfoutput>
#FORM["newsletter-text-input"]#
</cfoutput>


Cfdevshop
03-18-2013 @ 11:57 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Member
Posts:
Joined: Mar 2013

method must be "post" and naming must be simpler
now correct code is
<form id="newsletter-form" action="newsletter.cfm"
method="post">
  <input type="text" name="newslettertextinput"
id="newslettertextinput"  value="" placeholder="your
email..." />
  <input type="submit" name="newsletter"
value="Submit"/>
</form>
<!--- action page--->
<cfoutput>
#Form.newslettertextinput#
</cfoutput>

Coldfusiondevshop


Website Designed and Developed by Pablo Varando.