Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using form page as action page

Status
Not open for further replies.

Leakyradiator

Technical User
Jul 12, 2002
35
US
I am using two forms to collect data. On the first form I collect name, address, etc. information. The action page for the first form inserts the data and uses a cflocation to send to 2nd form. On the second form I want the user to be able to add as many categories as he wants into the database, but each one has to be in a separate record. The second form has two fields, the category, and two radio buttons answering the question "do you want to add another category? yes/no". The "action" of the form page points to itself. If the user clicks no, the action page will insert the data and say the process is complete. If the user clicks Yes, I want the data inserted, the page to present the data entered, and set up the form for the next category. If the user inputs three times, I want all three categories to be presented.

I hope this is clear. I know I've seen somewhere forms that use themselves as their own action pages, but can't find it. The trouble for me is in figuring out how the form determines whether it's being accessed from the first form, or form itself. Any guidance is greatly appreciated.

Thanks.
 
I do not totally understand your scenario - but I hope this is useful...

My suggestion would be to give different names to the buttons and then use CFIF to identify the buttons that was used and direct to appropriate code within the same page.

Hope this helps...

:)
 
There are two ways you might be able to do this.
As Extras suggests, you can name the submit button on Form 1 and the submit button on Form 2 different names:

page 1 -
Code:
<FORM action=&quot;form2.cfm&quot; method=&quot;POST ...>
   :
  <INPUT TYPE=&quot;submit&quot; NAME=&quot;form1submit&quot; ID=&quot;form1submit&quot; VALUE=&quot;Next&quot;>
</FORM>

page 2 -
Code:
<FORM action=&quot;form2.cfm&quot; method=&quot;POST ...>
   :
  <INPUT TYPE=&quot;submit&quot; NAME=&quot;form2submit&quot; ID=&quot;form2submit&quot; VALUE=&quot;Next&quot;>
</FORM>

Then at the top of page 2, you'd test which button was pressed:
Code:
<CFIF IsDefined(&quot;FORM.form1submit&quot;) AND FORM.form1submit EQ &quot;Next&quot;>
    The submit is from form 1
<CFELSEIF IsDefined(&quot;FORM.form2submit&quot;) AND FORM.form2submit EQ &quot;Next&quot;>
    The submit is from form 2
</CFIF>


Or you could put a hidden field in each form that contains the page number... this makes the check just a triffle easier... but it's really just 6 of one...

page 1 -
Code:
<FORM action=&quot;form2.cfm&quot; method=&quot;POST ...>
   :
  <INPUT TYPE=&quot;hidden&quot; NAME=&quot;pageNum&quot; ID=&quot;pageNum&quot; VALUE=&quot;1&quot;>
  <INPUT TYPE=&quot;submit&quot; NAME=&quot;submit&quot; ID=&quot;submit&quot; VALUE=&quot;Next&quot;>
</FORM>

page 2 -
Code:
<FORM action=&quot;form2.cfm&quot; method=&quot;POST ...>
   :
  <INPUT TYPE=&quot;hidden&quot; NAME=&quot;pageNum&quot; ID=&quot;pageNum&quot; VALUE=&quot;2&quot;>
  <INPUT TYPE=&quot;submit&quot; NAME=&quot;submit&quot; ID=&quot;submit&quot; VALUE=&quot;Next&quot;>
</FORM>

Then at the top of page 2:
Code:
<CFPARAM NAME=&quot;FORM.pageNum&quot; DEFAULT=&quot;1&quot;>

<CFSWITCH expression=&quot;#FORM.pageNum#&quot;>
<CFCASE value=&quot;1&quot;>
    The submit is from form 1
</CFCASE>
<CFCASE value=&quot;2&quot;>
    The submit is from form 2
</CFCASE>

</CFSWITCH>

Hope it helps,
-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top