Forum Moderators: open

Message Too Old, No Replies

Create combo box from database

combo box dynamically

         

ofie2

5:07 am on May 29, 2009 (gmt 0)

10+ Year Member



I have an interesting problem. Hoping someone may have an easy answer.

I have a form that has a combo box that pulls values from the database. The concept is
Option 1: [combo box with values a, b, c, d that are pulled from a mysql query]

Then, if you click an [add] button you get another combo box (Option 2: [combo box with values a, b, c, d that are pulled from the mysql query].

This way if you only want one option, you can pick it. If you want multiple options, you can have as many as you want.

I've done this successfully with javascript calling createElement('input'), and createElement('TEXTAREA') but I've never done it with createElement('option'). I can't seem to find any posts or tutorials that address this.

Thanks,
Ofie

httpwebwitch

4:52 am on Jun 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



don't forget about Select Multiple [w3schools.com]

I think you want to add a new Option [w3schools.com] object to the options[] array of a Select [w3schools.com] object.

Here's an example [w3schools.com].