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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.