I have a problem with creating an script which will fill one combobox
on base of what is selected in the other combobox
.
I am newbie in the field of PHP / JS so please be patient with me. Here it is what I have done so far:
js script which is on click event
<script type="text/javascript">
function selectDropdown(){
var dropdownValue=document.getElementById("dropdown").value;
$field=dropdownValue;
}
</script>
Base combobox filled with values from database:
<select id="dropdown" name="dropdown" onchange="selectDropdown()">
<option value="dd">--take an option--</option>
<?
$standard = Env::value('standard');
if (!$status)
$statement = "select code from standard";
foreach ($db->query($statement )->fetchall() as $row)
echo "<option".($row == $standard ? ' selected ' : '').">$row[0]</option>";
?>
</select>
and now I want to put the selected option into other combobox - actually I will execute another SQL query with the value chosen previously but the fact that I will have value in variable is more then enough for me to finish the task.
<select name='st' class='txt'>
<option value="st"><? echo $field; ?></option>
</select>
Posted code is created based on one of the articles I found, I have remake it according to my needs but this does not work. Could anyone point me where I am doing mistake?