This is a discussion on dynamic css within the Coding Help forums, part of the Webmaster Help category; im working on a video on demand project which is built which php, html, javscript and mysql as well as ...
| |||||||
| Register | Forum Rules | FAQ | Donate | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||||
| First create the select menu. Code: <select name='style' id='style'> <option value='_1'>style 1</option> <option value='_2'>style 2</option> </select> Code: <?php
$style_set = "_1";//set the default
if(@$_REQUEST['style'] <> ""){
$style_set = $_REQUEST['style'];
$_SESSION['set_style'] = $style_set;
header("Location: ".$_SERVER['PHP_SELF']);//redirect so we can show the changes to the style
}
if(isset($_SESSION['set_style'])){$style_set = $_SESSION['set_style'];}
//set style if session isset
?>
Code: <?php echo "<link rel=\"stylesheet\" href=\"style$style_set.css\" media=\"all\" />"; ?> Code: $style_set = rs['style'];
__________________ :. Web Design & Development Web Design Ireland :. Search Engines Optimization Search Engines Optimization :. Directory Submission Directory Submission :. News & Press Release Ireland GiveItSocks.com :. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories :. I Have 2 Find It Directory SEF Directory Last edited by louie; 09-10-2006 at 12:53 PM. |
| |||||
| show me what you have and i'll take a look at it |
| |||||
| have a look here: Code: <?php session_start(); ob_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="XHTML namespace"> <?php $style_set = "_1";//set the default if(@$_REQUEST['style'] <> ""){ $style_set = $_REQUEST['style']; $_SESSION['set_style'] = $style_set; header("Location: ".$_SERVER['PHP_SELF']);//redirect so we can show the changes to the style } if(isset($_SESSION['set_style'])){$style_set = $_SESSION['set_style'];} //set style if session isset ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <?php echo "<link rel=\"stylesheet\" href=\"style$style_set.css\" media=\"all\" />"; ?> </head> <body> <form name="select_style" action="x_style_set.php" method="post"> <select name="style" onChange='this.form.submit();'> <option value='_1' <?php if($style_set == "_1"){echo "selected";}?>>style 1</option> <option value='_2' <?php if($style_set == "_2"){echo "selected";}?>>style 2</option> </select> </form> <?php echo "your style that you have selected is - <b>style$style_set.css</b>";?> </body> </html> Last edited by louie; 10-10-2006 at 08:12 AM. Reason: added code |
| |||||
| you are welcome. |
| Tags |
| css, dynamic |
| Thread Tools | |
| Display Modes | |
|
|
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to make a H1 tag in CSS into a link | shanediffily | Coding Help | 4 | 10-10-2006 04:54 PM |