OK, I am not going to give you the full PHP thing, it looks like there are too many variables. Basically you could create ALL your rows using the method I illustrate below to create all your font options in one loop.
So..... Lets start with this:
Code:
<!-- Copyright 2005 - 2008 RL Hanson-Online //-->
<?
$fontData=array('443'=>'Arial','444'=>'Book Antiqua Italic','445'=>'Bradley Hand ITC','446'=>'Century Gothic','447'=>'Comic Sans MS','448'=>'Copperplate Gothic Bold','449'=>'Courier','461'=>'edwardian script ITC','462'=>'Garamond','463'=>'Georgia','464'=>'Haettenschweiler','482'=>'Helvetica','483'=>'Impact','484'=>'Lucida Handwriting','485'=>'Monotype Corsiva','486'=>'Tahoma','487'=>'Times New Roman','488'=>'Trebuchet MS','489'=>'Verdana');
$selOptions="";
$jsArray="";
while (list($key,$val) = each($fontData)) {
// Make sel options based on data in $fontData so we can reuse it many times
$selOptions.="\n<option value=\"$key\">$val</option>";
$jsArray.="\nfontData[$key]='$val';";
}
// this will create the JS array we had in des_function
echo "<script>\nfontData=[];$jsArray\n</script>";
$selOptions.='<option value="choose" selected="selected">-- Choose Style --</option>';
?>
<script type="text/javascript" src="des_function.js"></script>
Naturally the file probably has to be renamed to php.
Insert the php code above where indicated. It will then create your select options all at once, AND create the JS array you can now dump from des_... (view source and you will see it)
Step 2 is to write your selects like this:
Code:
<select name="optn33" id="select_companyName" onChange="changeFont('companyName')">
<?
echo $selOptions;
?>
</select>
....
<select name="optn34" id="select_sloganS" onChange="changeFont('sloganS')">
<?
echo $selOptions;
?>
</select>
Finally, replace everything in des_function with this.
Code:
function changeFont(changevar)
{
// This function gets called when selection changes
var s=document.getElementById("select_"+changevar);
if( s.selectedIndex == -1 ) return;
var v = s.options[s.selectedIndex].value;
var theobjtoChange=document.getElementById(changevar);
theobjtoChange.style.fontFamily=fontData[v];
}
Wanna really get fancy?
in the PHP code, change this:
$selOptions.="\n<option value=\"$key\">$val</option>";
to this:
$selOptions.="\n<option value=\"$key\" style=\"font-family: $val;\">$val</option>";