Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

Dynamic Action and submit

Javascript coding ..

Moderators: macek, egami, gesf

Dynamic Action and submit

Postby popeye » 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();'>
</form>


Any Ideas? I appriciate any help.
User avatar
popeye
New php-forum User
New php-forum User
 
Posts: 120
Joined: Sat Jan 03, 2004 7:06 pm
Location: New York, NY

Re: Dynamic Action and submit

Postby reyborn » Tue Jul 19, 2011 7:44 pm

Try the following code:

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

<form id="form" method='POST' action=''>
<input type='button' value='Save' onclick="SubmitForm('save.php');">
<input type='button' value='Search' onclick="SubmitForm('search.php');">
</form>
reyborn
New php-forum User
New php-forum User
 
Posts: 9
Joined: Wed Mar 30, 2011 7:36 am


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron