954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Multiple Submit Button

Hi,

I am new to ColdFusion , so i need so help from all....

I am going to do a form having multiple submit buttons in it .
So how can i know which button was clicked. according to this i want different work...

Like simple i want to do add, sub, mul and div in one form.
I have used 4 submit buttons for this after submiting the page i want to reload that page and do accordingly which button was clicked.

So how can i know which button was clicked.
Please respond me...
Thanks

Ashish

aksahoo17
Newbie Poster
20 posts since Nov 2010
Reputation Points: 10
Solved Threads: 1
 
<cfif StructKeyExists(form,"submit0">
 //logic here
</cfif>

<cfif StructKeyExists(form,"submit1">
 //logic here
</cfif>

<cfif StructKeyExists(form,"submit2">
 //logic here
</cfif>

<cfif StructKeyExists(form,"submit3">
 //logic here
</cfif>

<input type="submit" name="submit0" value="submit0" />
<input type="submit" name="submit1" value="submit1" />
<input type="submit" name="submit2" value="submit2" />
<input type="submit" name="submit3" value="submit3" />

Try that out?

cfwebdeveloper
Junior Poster in Training
78 posts since May 2011
Reputation Points: 19
Solved Threads: 8
 
So how can i know which button was clicked.

Only the button clicked will exist on the action page. If all 4 buttons share the same name, use the button value ie #form.submitButton#

ie

<cfparam name="form.submitButton" default="">
<!--- display selection --->
<cfdump var="#form#">

<form method="post">
<input type="submit" name="submitButton" value="add" />
<input type="submit" name="submitButton" value="divide" />
<input type="submit" name="submitButton" value="multiply" />
<input type="submit" name="submitButton" value="divide" />
</form>
arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

Thanks it worked greatly thanks once more.....:)

aksahoo17
Newbie Poster
20 posts since Nov 2010
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You