Re: buttons and "action"
- From: brkn <msousa@xxxxxxxxxx>
- Date: Fri, 27 Nov 2009 19:19:09 -0800 (PST)
On Nov 23, 6:02 am, richard <mem...@xxxxxxxxxxx> wrote:
<form id="chooser" action="chooser.php" method="post">
<button type="submit" name="plan" value="basic">
On my web page I'm building I will have a two column layout with header.
The left column will have the menu which I think I can do better with
buttons. What all can I do with "action"?
As that is obviously the key to making it all work when a button is clicked
on.
When the page loads, an initial page loads in the right column.
When user clicks a button, that page is changed. I've seen this done before
so I know it will work.
So how do I pass a value on to the next step?
For instance, my variable will be named $item.
<?PHP
if ($item=="basic"){echo "basic"}
?>
Yeah, I'd have to say that a switch statement would be best in this
scenario. You can pass the values through the url (ex: www.yourwebsite.com?p=basic).
<?PHP
if (isset($_GET['p'])) {
$p = $_GET['p'];
} elseif (isset($_POST['p'])) {
$p = $_POST['p'];
} else {
$p = NULL;
}
switch ($p) {
case 'basic';
$page = 'basic.html';
break;
case 'advanced';
$page = 'advanced.html';
break;
default:
$page = 'basic.html';
break;
}
include ('pages/' . $page);
?>
http://php.net/manual/en/control-structures.switch.php
.
- Follow-Ups:
- Re: buttons and "action"
- From: Scott Johnson
- Re: buttons and "action"
- References:
- buttons and "action"
- From: richard
- buttons and "action"
- Prev by Date: Re: timestamp at start of filling out form and form completion
- Next by Date: Re: what's wrong with this array? Parse error
- Previous by thread: Re: buttons and "action"
- Next by thread: Re: buttons and "action"
- Index(es):
Relevant Pages
|