ColdFusion Tutorial

Several submit buttons in one form

If you need to have several submit buttons in on form, where each button perform different task you can use this code.

First make a JavaScript on top of your page.

<script language="javascript">
<!--
function changeFormAction(anAction)
{
 
document.Add_Update.action = anAction;
document.Add_Update.submit();
}
//-->
</script>


The form action on your page.

<form action="" NAME="Add_Update" METHOD="POST">
     code
</form>

Notice: Remember that the name parameter in your form must be the same as the document parameter in your JavaScript. In this example we use the name "Add_Update" in the form, so in the JavaScript change document.something?.. to document.Add_Update.action = anAction and document.something? to document.Add_Update.submit();

You have to add the event onClick="changeFormAction to your submit buttons.

The "Reset" button do not call the JavaScript. 

Example:

<script language="javascript">

<!--

function changeFormAction(anAction)

{

document.Add_Update.action = anAction;

document.Add_Update.submit();

}

//-->

</script>

<form action="" NAME="Add_Update" METHOD="POST">

<input name="Add_button" type="submit" id= "Add_button"onClick="action='Add'" value="Add">

<input name="Update_button" type="submit" id= "Update_button" onClick="action='Update'" value="Update">

<input name="Reset_button" type="reset" id="Reset_button" value="Reset">

</form>

ColdFusion Tutorial test

Several submit buttons in one form

No test is available or implemented for this ColdFusion Tutorial.

User Comments: 1

 Good stuff

thanks, this is just what the Dr. Ordered :-)

Add your comments

Your Name*:
Your Email:
Site URL:
Site Name:
Comemt Title*:
Your Comment*:
Key Phrase*:
Ih1
Your IP Address: 38.103.63.62
 

ScandicWeb is own by Scandic Systems LTD [UK] Company No. 5984000. All other trademarks and copyrights are the property of their respective holders.

[Home [Site Map [Privacy Statement [Site Feedback] [About ScandicWeb]


[ColdFusion [Flash [Search Engine Optimization [Graphics [Cascading Style Sheets (CSS) [JavaScript (JS) [Software]

Partner sites: ScandicSoft


Server time: 19. November 2008 Wednesday