2 controls submit one form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alexmaster_2004
Forum Commoner
Posts: 35
Joined: Wed Sep 14, 2005 8:44 am

2 controls submit one form

Post by alexmaster_2004 »

Hi
I have a web page that contain 2 different controls(Button,DropDownBox).
the 2 controls can submit the form.
I want to know if there is a way to know whiche control have sumitted the form.
i want to konw this because i want to redirect that page to one of other 2 pages
depend on the control that have submitted it.
Thanks
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

well since you are obviously using javascript you can have a hidden field then when its submitted but the dropdown box change the value of that dropdown box to "dropdown" or somthing, then for the other (lets say submit button) just have the value changed to "submit_btn" or just keep the default. then on the next page check the value of the hidden field and go from there
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if they are named differently, you'll know which was used ;)
alexmaster_2004
Forum Commoner
Posts: 35
Joined: Wed Sep 14, 2005 8:44 am

Post by alexmaster_2004 »

Hi
I named them differently.but really don't know how to do this.
i don't want to use javascript.
i hope you can tell me what i can do.
Thanks
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Code: Select all

<?
if(isset($_POST['bobby']))
	echo "submit button clicked";
else if(isset($_POST['bob']))
	echo "select changed";
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>

<body>
<form method="post" name="MyForm">
<select name="bob" onChange="document.MyForm.submit()">
<option value=""></option>
<option value="1">1</option>
<option value="2">2</option>
</select>

<input type="submit" name="bobby">
</form>


</body>
</html>
Post Reply