option select color css code example

Example: change background color with user option

<form action="" method="post">

<select name="Color">
	<option value="White">White</option>
	<option value="Red">Red</option>
	<option value="Green">Green</option>
	<option value="Blue">Blue</option>
	<option value="Pink">Pink</option>
	<option value="Yellow">Yellow</option>
</select>

<input type="submit" name="submit" value="Get Selected Values" />

</form>
<?php

if(isset($_POST['submit'])){

	$selected_val = $_POST['Color'];  // Storing Selected Value In Variable
	echo "<style>body{background-color:".$selected_val.";}</style>";  // Displaying Selected Value

}

?>

Tags:

Css Example