Dynamic Action and submit

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply

Mon Jul 18, 2011 11:46 am

I can not get this action and submit to work and load up the right action php script.

Code: Select all

<form method='POST' action=''>
<input .....>
<input type='button' value='Save'  onnclick='this.form.action.value="Save.php";this.form.submit();'>
<input type='button' value='Search' onclick='this.form.action.value="Search.php";this.form.submit();'>
Any Ideas? I appriciate any help.

New php-forum User
New php-forum User
Posts: 9
Joined: Wed Mar 30, 2011 7:36 am

Tue Jul 19, 2011 7:44 pm

Try the following code:

<script type="text/javascript">
function SubmitForm(value) {
document.getElementById("form").action = value;

<form id="form" method='POST' action=''>
<input type='button' value='Save' onclick="SubmitForm('save.php');">
<input type='button' value='Search' onclick="SubmitForm('search.php');">

Post Reply