...

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



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

JordanW
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";
}
else
if(document.pressed == 'Page 2')
{
document.form1.action ="page2.php";
}
return true;
}

</script>

<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">

</form>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum