create a function which submits the page
pass the form action flag as an argument
example... (not tested)
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script>
// function
function submitter(a){
// set form target in var
form = document.getElementById('form1');
// use switch to determin which button has been clicked and set what results page to use
switch(a){
case '1': var act = "page1.php"; break;
case '2': var act = "page2.php"; break;
}
// set action of form
form.action = act;
// submit form
form.submit();
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p><input type="text" name="textfield2" /></p>
<p><input type="text" name="textfield" /></p>
<p>
<input name="button1" type="button" id="button1" value="Button1" onclick="submitter('1')"/>
<input name="button2" type="button" id="button2" value="Button2" onclick="submitter('2')"/>
</p>
</form>
</body>
</html>