Seeking assistance with formatting this JavaScript array accurately. It seems like I am overlooking something crucial:
Javascript:
<script type="text/javascript">
var dimensions = new Array("225","320","480", "--");
var walls = new Array();
walls["225"] = new Array("65","55","45","40", "--");
var wheels["225"] = new Array();
wheels["225"]["65"] = new Array("R17", "--");
wheels["225"]["55"] = new Array("R17","R18", "--");
wheels["225"]["45"] = new Array("R17", "--");
wheels["225"]["40"] = new Array("R18", "--");
walls["320"] = new Array("70", "--");
var wheels["320"] = new Array();
wheels["320"]["70"] = new Array("R20","R24", "--");
walls["480"] = new Array("65", "--");
var wheels["480"] = new Array();
wheels["480"]["65"] = new Array("R28", "--");
</script>
PHP utilized to produce the above JavaScript:
<?php while($row = mysql_fetch_array($result)) {
list($dimension, $wall, $wheel) = explode("/",$row['meta_value']); $menu[$dimension][$wall][$wheel] = 1; }
$dimensions = implode('","', array_keys($menu));
print "var dimensions = new Array(\"$dimensions\", \"--\");\n";
print "\nvar walls = new Array();\n";
foreach($menu as $dimension => $wall_array) {
$walls = implode('","', array_keys($wall_array));
print "walls[\"$dimension\"] = new Array(\"$walls\", \"--\");";
print "\nvar rims[\"$dimension\"] = new Array();\n";
foreach($wall_array as $wall => $rim_array) {
$wheels = implode('","', array_keys($rim_array));
print "wheels[\"$dimension\"][\"$wall\"] = new Array(\"$wheels\", \"--\");";
}
} ?>
Your support is much appreciated.
Stu