Page 1 of 1
2 controls submit one form
Posted: Sun Sep 18, 2005 10:58 am
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
Posted: Sun Sep 18, 2005 12:22 pm
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
Posted: Sun Sep 18, 2005 12:23 pm
by feyd
if they are named differently, you'll know which was used

Posted: Sun Sep 18, 2005 3:20 pm
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
Posted: Sun Sep 18, 2005 3:38 pm
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>