Forum Moderators: coopster
<div id="WT_BG">
<div id="#trunks_form_container">
<div id="page_headings"><img src="images/page_headings/personalise.png" alt="design your own trunks" /></div>
<div id="personalise_LH_text"></div>
<div id="trunks_front">
<div id="trunks_container"><img name="trunks" src="images/plain-trunks-front_2nd.png" width="425" height="255" alt="" />
<div id="text_return_container">
<?php
$text_size = $_POST['size'];
$font = $_POST['font'];
$colour = $_POST['colour'];
$bg = $_POST['bg'];
$text = $_POST['personalise'];
echo "<span style=\" font-family:$font; color:$colour; font-size:$text_size; \">
$text
</span>\n";
?>
</div><!--end text return container-->
</div><!--end trunks container-->
<?php
"<span style=\" bgcolor:$bg\"></span>\n";
echo "$bg";
?>
</div><!--end trunks front-->
</div>
<!--end trunks form container-->
<div id="personalise_form">
<form method="POST" action="<?php echo $PHP_SELF;?>">
<p> <input type="text" name="personalise" value="Enter your text here" onfocus="if(this.value == 'Enter your text here') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter your text here';}"/></p>
<?php
// you need the values of your combobox in an array
$colourvalues = array('black','white','red','green','blue','orange','purple','cyan','pink');
$fontvalues = array('arial','helvetica','trebuchet MS','arial black','lucida console','verdana','comic sans MS','courier new','impact','century gothic','bookman old style','Microsoft Sans Serif');
$sizevalues = array('20px','30px','40px','50px','60px');
$trunkvalues = array('#000000','white','red','green','blue','orange','purple','cyan','pink');
echo '<select name="colour">';
for($x = 0; $x < count($colourvalues); $x++)
{
// write "selected" if the value matches the one posted
if($colourvalues[$x] == $_POST['colour'])
{
$colourselected = ' selected';
}else{
$colourselected = '';
}
// print the option
echo '<option value="'.$colourvalues[$x].'"'.$colourselected.'>'.$colourvalues[$x].'</option>';
}
echo '</select>';
echo '<select name="font">';
for($y = 0; $y < count($fontvalues); $y++)
{
// write "selected" if the value matches the one posted
if($fontvalues[$y] == $_POST['font'])
{
$fontselected = ' selected';
}else{
$fontselected = '';
}
// print the option
echo '<option value="'.$fontvalues[$y].'"'.$fontselected.'>'.$fontvalues[$y].'</option>';
}
echo '</select>';
echo '<select name="size">';
for($w = 0; $w < count($sizevalues); $w++)
{
// write "selected" if the value matches the one posted
if($sizevalues[$w] == $_POST['size'])
{
$sizeselected = ' selected';
}else{
$sizeselected = '';
}
// print the option
echo '<option value="'.$sizevalues[$w].'"'.$sizeselected.'>'.$sizevalues[$w].'</option>';
}
echo '</select>';
echo '<select name="bg">';
for($z = 0; $z < count($trunkvalues); $z++)
{
// write "selected" if the value matches the one posted
if($trunkvalues[$z] == $_POST['bg'])
{
$trunkselected = ' selected';
}else{
$trunkselected = '';
}
// print the option
echo '<option value="'.$trunkvalues[$z].'"'.$trunkselected.'>'.$trunkvalues[$z].'</option>';
}
echo '</select>';
?>
<p><input type="submit" name="submit" value="Show me this text on my briefs"/></p>
</form>
</div>
</div>
</code>
it doesn't matter what i try, i cannot get the background colour of 'trunks_front' div to change dynamically.
can anyone suggest what i am doing wrong here?
it's the background colour of trunks_front that i want to change. the variable is $bg for this. the string is assigned via a form in which you can select the various colours.