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 :-)
