For the last two days, I have been butting my head against my monitor trying to send data to a drop-down menu from a JavaScript. Here's the JavaScript:
<script>
function myFunction(str)
{
var SystemNum = str;
alert(SystemNum);
document.getElementById("TechNum").value = SystemNum;
alert(document.getElementById("TechNum").value);
location.reload(true);
}
</script>
And the PHP:
echo '<form name="SystemForm" action="Retrieve.php" method="post" >';
echo '<select name="SystemNum" size="8" multiple="multiple" style="text-align:left;" onChange = "myFunction(this.value)">';
echo '<option value = "0">All Systems In Texoma</option>';
$result = mysql_query("SELECT * FROM Systems ORDER BY LongSystem");
while($row = mysql_fetch_array($result));
{
$SystemNum = $row['SystemNum'];
echo '<option value = "' . $SystemNum . '">' . $row['LongSystem'] . '</option>';
}
echo '</select>';
echo '<div class = "center" style="width:400px; margin:auto">';
echo '<select name="TechNum" id = "TechNum" size="8" multiple="multiple" style="text-align:left;">';
echo '<option value="0">All Techs in System</option>';
Because of the alert at the beginning of the function, I know that the value of the selected menu item is being passed correctly to the function. Why then, is the value not being passed to the "document.getElementById()" statement?
There has to be a simple solution that I'm overlooking.