Dynamic Action and submit

Javascript coding ..

Moderators: macek, egami, gesf

Post Reply
User avatar
New php-forum User
New php-forum User
Posts: 121
Joined: Sat Jan 03, 2004 7:06 pm
Location: New York, NY

Dynamic Action and submit

Post by 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();'>
Any Ideas? I appriciate any help.

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

Re: Dynamic Action and submit

Post by reyborn » 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

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest