Jump to content

Recommended Posts

Hi Guys,

 

I have this piece of code"a form" that submits to the product.php when the submit button is clicked but I want the same input fields to be posted to a different script when a continue button is clicked!!!

<form method="post" action="product.php">
		<table width="200" cellpadding="2" cellspacing="0" border="0" >
			<tr>
				<td style="width:100;">
					Frame
				</td>
				<td style="width:100; padding-bottom:10px;">
					<select name="frame" id="frame">
					  <option>Volvo</option>
					  <option>Saab</option>
					  <option>Mercedes</option>
					  <option>Audi</option>
					</select>
				</td>
			<tr>
			<tr>
				<td style="width:100;">
					Size
				</td>
				<td style="width:100; padding-bottom:10px;">
					<select name="size" id="size">
					  <option>Volvo</option>
					  <option>Saab</option>
					  <option>Mercedes</option>
					  <option>Audi</option>
					</select>
				</td>
			<tr>
			<tr>
				<td style="width:100;">
				</td>
				<td style="width:100; text-align:right;">
					<input type="submit" value="Submit">
				</td>
			</tr>
		</table>
	</form>

 

Guys I need your help with how to submit the same form/fields to different scripts when different buttons are clicked!

 

Thanks for helping - Zahid

 

Link to comment
https://forums.phpfreaks.com/topic/146310-solved-form-submit/
Share on other sites

you could use javascript to select it out

 

<script lang="javascript"> 
<!-- 
function subit(which) { 
if (which == 1) { 
  document.myform.action = 'somepage.php?who=1'; 
} else if (which == 2) { 
  document.myform.action = 'somepage.php?who=2'; 
} 
document.myform.submit(); 
} 
//--> 
</script> 
<form method="post" name="myform"> 
Type Name:<br> 
<input type="text" name="username" value = ""> 
<input type="button" value="Your name" onClick="javascript:subit(1);"> 
<input type="button" value="Child's name" onClick="javascript:subit(2);"> 
</form>

somepage.php

<? 
if ($_GET['who'] == 1) { 
echo "who equals 1"; 
} else if ($_GET['who'] == 2) { 
echo "who equals 2"; 
} 
?>


<script lang="javascript"> 
<!-- 
function subit(which) { 
if (which == 1) { 
  document.myform.action = 'somepage.php?who=1'; 
} else if (which == 2) { 
  document.myform.action = 'somepage.php?who=2'; 
} 
document.myform.submit(); 
} 
//--> 
</script> 
<form method="post" name="myform"> 
Type Name:<br> 
<input type="text" name="username" value = ""> 
<input type="button" value="Your name" onClick="javascript:subit(1);"> 
<input type="button" value="Child's name" onClick="javascript:subit(2);"> 
</form>

somepage.php

<? 
if ($_GET['who'] == 1) { 
echo "who equals 1"; 
} else if ($_GET['who'] == 2) { 
echo "who equals 2"; 
} 
?>

Link to comment
https://forums.phpfreaks.com/topic/146310-solved-form-submit/#findComment-768124
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.