Page 1 of 1
Drop Down Styles...
Posted: Sun Sep 22, 2002 6:40 am
by Dale
How do i make a drop down thing select a colour...
Example:
(Drop Down Menu):
[ Green ]
| Blue | <-- I select Blue
[ Red ]
Then when i select my colour the INCLUDE tag on my page changes...
Include tag:
Code: Select all
<?php include ("./colour/$sc"); ?>
<b>$sc</b> being the colour selected.
Is it possible to do that?
Posted: Sun Sep 22, 2002 7:08 am
by phpPete
If you want to change the include() arguments on the page you are currently displaying, you can't, since by the time you see the page, PHP is done with it's processing for that page on the server, so you're viewing the finished page in your browser, the client.
You can simulate it by having the page post back to itself when you select a color, passing the selected value.
Posted: Sun Sep 22, 2002 7:10 am
by Dale
ok...
Posted: Sun Sep 22, 2002 11:53 am
by hob_goblin
you will need some JS for this:
Code: Select all
<form method="post" action="thispage.php" name="foo">
<select name="cs" onChange="javascript:document.foo.submit();">
<option value="green">Green</option>
<option value="blue">Blue</option>
<option value="red">Red</option>
</select>
</form>
<?
if(isset($_POSTї'cs'])){
include("./colour/$cs");
} else {
include("./colour/blue"); // DEFAULT
}
?>
yeah, or something like that, you'll need javascript though.
Posted: Mon Sep 23, 2002 1:55 am
by twigletmac
Don't forget to add a submit button in some <noscript></noscript> tags for those people who don't have (or don't want) javascript.
Mac
Posted: Wed Sep 25, 2002 2:24 pm
by Dale
ok thx
