Well, here's what it does. some php echos out a bunch of javascript variables. then the user makes a select box choice. the select box choice value equals the 'dt number', which is part of the javascript variables outputted by php. so i then need to be able to have javascript access a dynamically named variable.
Thus:
Code:
function selector()
{
var selected = document.selectForm.selectBox.options[document.selectForm.selectBox.selectedIndex].value;
<?
// import employee data into javascript //
$sql2 = "SELECT dt FROM employment";
$sql2 = mysql_query($sql2);
while ($row = mysql_fetch_array($sql2, MYSQL_ASSOC))
{
foreach ($row as $dt)
{
$sql3 = "SELECT name FROM employment WHERE dt=".$dt;
$sql3 = mysql_query($sql3);
$name = mysql_result($sql3,0);
echo "var dt" . $dt . "_name = '" . $name . "';\n";
}
}
?>
var current = 'dt' + selected + '_name';
document.write(current);
}