Jump to content

[SOLVED] Problem filling dropdown from database


Thierry

Recommended Posts

I have a dropdown in a form, and based on what you select in that dropdown, another dropdown can contain various options.

 

I'm using the script below but it gives the "not supported by this object" error, although it does manage to create the first option succesfully, but none of the others.

 

$counter = 0;
while($row = mssql_fetch_array($result)){

$uur_id = $row["uur_id"];
$uur_naam = $row["uur_naam"];

if($counter == 0){ ?>
<script language="Javascript">
<!--
var dropdown = parent.document.getElementById("uur_id");
var keuzevak = new Option;
<? } ?>
keuzevak.text = "<? echo $uur_naam; ?>";
keuzevak.value = "<? echo $uur_id; ?>";
dropdown.options[<? echo $counter; ?>] = keuzevak;
<? ++$counter;} ?>
-->
</script>

 

Any idea what I'm doing wrong?

 

EDIT: Never mind, forgot to put the New Option part within the loop.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.