Page 1 of 1

set background color doesn't work

Posted: Wed Oct 14, 2015 8:34 am
by maichel

I have made code. The meaning is if you click on the color in the <option> then the background color change.
But this doesn't work.

Can someone help me?

thanks in advance.

Code: Select all


$red = "";
$yellow = "";
$blue = "";
$orange = "";
$purple = "";

if (isset($_POST['color'])) {$color = $_POST['color'];}
else {$color = '';}

<title>color changer</title>
<style> { background-color: red; }
option.yellow { background-color: yellow; } { background-color: blue; } { background-color: #FF8040; }
option.purple { background-color: #800080; }

<body bgcolor="<?php echo color; ?>">

<form action="" method="POST">
<select name="background">
		<option style="display:none;" selected="selected">color</option>
		<option class="red" value="red" <?php echo $red; ?>>Red</option>
		<option class="yellow" value="yellow" <?php echo $yellow; ?>>Yellow</option>
		<option class="blue" value="blue" <?php echo $blue; ?>>Blue</option>
		<option class="orange" value="orange" <?php echo $orange; ?>>Orange</option>
		<option class="purple" value="purple" <?php echo $purple; ?>>Purple</option>
<input type="submit" name="submit" value="change">