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

Recommended Answers

All 3 Replies

<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?

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>

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.