Hi,

I have a table in my database that´s like that:
create table t(
id int,
name varchar(30),
father_id int,
Primary Key(id),
Foreign Key(father_id) references t(id)
);

I´m trying to do the follow:

1) Create a select box witch each option has an id, that when selected it search on the db table t for the father_id.
2)If this search returns anything it will create with dom(create element) a new select.
3)This select created also will search in the db table t for father_id.

Did anyone knows, how can i do that?

Well the javascript would be something along the lines of

var newElement = document.createElement('option');
newElement.text = <name variable here>;
newElement.id = <id variable here>;
newElement.value = <whatever else here>;
var targetSelect = getElementById('whatever the select id is');
try{targetSelect.add(newElement,null);}catch(ex){targetSelect.add(newElement);}

That creates a new element then adds it as a child element to the select box. The try/catch is there because IE doesn't conform to standards.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.