?
Solved

executing multiple submit buttons on a single page

Posted on 2005-03-02
6
Medium Priority
?
1,544 Views
Last Modified: 2013-12-24
hi, i have the following two forms on the SAME page. both forms submit to the same page also (i.e page2.cfm).
is it possible to make it so that I also have one "Submit All" button that will submit both the forms.

i could put all the inputs into a single form but wanted to give the ability to submit the individual forms also.

<cfform name="Form1" action="page2.cfm" method="POST">
<tr>
<td><cfinput name="input1" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><cfinput name="input2" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><input name="Submit" type="Submit" value="Submit"></td>
</tr>
</cfform>

<cfform name="Form2" action="page2.cfm" method="POST">
<tr>
<td><cfinput name="input1" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><cfinput name="input2" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><input name="Submit" type="Submit" value="Submit"></td>
</tr>
</cfform>
0
Comment
Question by:Judy Deo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Assisted Solution

by:kkhipple
kkhipple earned 1000 total points
ID: 13443793
its possible... hwoever, i think the easiest way to do it is if you have one form  with three submit buttons

depending on which submit button the user clicks on, you collect certain info from the form...


i hope that gets you started..


<cfform name="Form1" action="page2.cfm" method="POST">
<tr>
<td><cfinput name="input1" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><cfinput name="input2" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><input name="Submit1" type="Submit" value="Submit"></td>
</tr>
<tr>
<td><cfinput name="input1" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><cfinput name="input2" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><input name="Submit2" type="Submit" value="Submit"></td>
</tr>
<tr>
<td><input name="Submit3" type="Submit" value="Submit All"></td>
</tr>
</cfform>




page2.cfm


<CFIF FORM.Submit EQ 'Submit1'>

<CFELSEIF FORM.Submit EQ 'Submit2'>

<CFELSEIF FORM.Submit EQ 'Submit3'>

</CFIF>
0
 
LVL 7

Assisted Solution

by:INSDivision6
INSDivision6 earned 100 total points
ID: 13444001
Only using JScript
0
 
LVL 17

Assisted Solution

by:Tacobell777
Tacobell777 earned 200 total points
ID: 13444604
<script>
function submitAll()
{
    document.Form1.submit();
    document.Form2.submit();
}
</script>


<input name="Submit3" type="Submit" onclick="submitAll();" value="Submit All">

BUT ( a big but ) this would not work unless you set the target of the form to be _blank
otherwise the first submit would submit the form from the page itself and not submit the next one...
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 35

Assisted Solution

by:mrichmon
mrichmon earned 200 total points
ID: 13445280
It is actually a bad idea and will not work in a lot of cases (especially problems using cfform)

What you should do is have one form.

Then have as many submit buttons as you like.

The page you submit to tests to see which button was clicked.

If only submit1 is clicked then it acts as if only the fields that used to be part of the first form were submitted.

If submit 2 is cliced it only looks at the fields from the second part.

If the submitall is clicked then it looks at all of the fields.


This way you have the flexibility you want, but also have proper coding.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 13445282
Oh I just realised that kkhipple gave you the code for this.  :o)  I overlooked that post at first....
0
 
LVL 14

Accepted Solution

by:
Renante Entera earned 500 total points
ID: 13446049
Hi sagardeo!

Just a correction on the posted code of kkhipple.  'Coz if you run that code, you might encountered problems like :
  1.  Input field "input1" is not unique.
  2.  Element "Submit" is not defined on the form.

Here's the revised one :

<!--- Take note on the name of the submit button.  It should be "Submit" 'coz you will refer to this on your submit page. --->
<cfform name="Form1" action="page2.cfm" method="POST">
<tr>
<td><cfinput name="input1" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><cfinput name="input2" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><input name="Submit" type="Submit" value="Submit1"></td>
</tr>
<tr>
<td><cfinput name="input3" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><cfinput name="input4" type="Text" size="5" validate="integer" required="Yes"></cfinput></td>
<td><input name="Submit" type="Submit" value="Submit2"></td>
</tr>
<tr>
<td><input name="Submit" type="Submit" value="Submit All"></td>
</tr>
</cfform>

:: page2.cfm ::
<!--- It would be better if you use "<cfswitch>" tag --->
<cfswitch expression="#form.Submit#">
  <cfcase value="Submit1">
    Submit 1
  </cfcase>
  <cfcase value="Submit2">
    Submit 2
  </cfcase>
  <cfdefaultcase>
    Submit All <!--- which is the default --->
  </cfdefaultcase>
</cfswitch>

Hope this helps you.  Just try it.


Goodluck!
eNTRANCE2002 :-)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question