Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

2 forms on same page

Explorer ,
Nov 27, 2008 Nov 27, 2008
Is it possible in Coldfusion(v8) to have 2 forms on the same page, name them and return the variable.

Something like this. although the form variable is a system variable so how would it work?

<cfdump var="#form.username#"></cfdump>
<cfdump var="#form2.email#"></cfdump>
TOPICS
Getting started
790
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 27, 2008 Nov 27, 2008
Yeah... You can have.. But you can submit one at a time...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2008 Nov 27, 2008
What Daverms says, plus

<cfif isDefined("form.username")>
<cfoutput>#form.username#</cfoutput>
or
<cfdump var="#form#">
</cfif>

<cfif isDefined("form2.email")>
<cfoutput>#form2.email#</cfoutput>
or
<cfdump var="#form2#">
</cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 27, 2008 Nov 27, 2008
I can't get it to work can someone post an exmaple please?

Thanks
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 27, 2008 Nov 27, 2008
What are you trying to do and what is happening when you try?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 29, 2008 Nov 29, 2008
<!--- use sbmt1, sbmt2 to distinguish between the submitted forms --->
<cfif isDefined("form.sbmt1")>
<cfset form1=form>
<cfelseif isDefined("form.sbmt2")>
<cfset form2=form>
</cfif>

<cfif isDefined("form1.username")>
form1.username: <cfoutput>#form1.username#</cfoutput><br>
form1 dump <cfdump var="#form1#">
</cfif>

<cfif isDefined("form2.email")>
form2.email: <cfoutput>#form2.email#</cfoutput><br>
form2 dump <cfdump var="#form2#">
</cfif>



<cfoutput><FORM action="#cgi.script_name#" method="post"></cfoutput>
User: <INPUT type="text" name="username"><BR>
<INPUT type="submit" name="sbmt1" value="Send">
</FORM>
</P>

<P>
<cfoutput><FORM action="#cgi.script_name#" method="post"></cfoutput>
Email: <INPUT type="text" name="email"><BR>
<INPUT type="submit" name="sbmt2" value="Send">
</FORM>
</P>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 03, 2008 Dec 03, 2008
Hulfy wrote:
...name them and return the variable

Do you mean something like this?

<FORM action="actionPage.cfm" method="post" name="myForm">
User: <INPUT type="text" name="username"><BR>
<INPUT type="submit" name="sbmt1" value="Send">
</FORM>

Then refer to the variable myForm.username? That may work in Javascript and other scripting languages, but I don't expect it will in Coldfusion. Upon submit, Coldfusion returns its own form structure, named, what else, form.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 04, 2008 Dec 04, 2008
LATEST
That's what was confusing me. So either name the submit or a hidden variable would do the trick.

This kind of answers my other question.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources