View Full Version : how to implement different behaviours of a form?

08-05-2007, 01:39 PM
hi all,
i have a form with two buttons and various text fields. i want to manipulate the field values on pressing any one button among two buttons.that is, if user clicks "button1" then the values are sent to same page(i.e.,PHP_SELF) also if user clicks "button2" then the values are sent to "page2.php". both are submit type buttons which are inside the form(only one form). how to do this?:rolleyes:

08-05-2007, 02:27 PM
Use javascript to manipulate the action of the form?

<script language="JavaScript">
function SubmitForm()

if(document.pressed == 'This Page')
document.form1.action ="thispage.php";
if(document.pressed == 'Page 2')
document.form1.action ="page2.php";
return true;


<form name="form1" onSubmit="return SubmitForm();">

<input type="submit" name="WhatToDo" onClick="document.pressed=this.value" VALUE="This Page">

<input type="submit" name="WhatToDo" onClick="document.pressed=this.value" VALUE="Page 2">