0

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?

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by ShawnCplus
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.