•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,807 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,827 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 826 | Replies: 1
![]() |
•
•
Join Date: Dec 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 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?
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?
•
•
Join Date: Apr 2005
Location: New York state
Posts: 468
Reputation:
Rep Power: 5
Solved Threads: 71
Well the javascript would be something along the lines of
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.
javascript Syntax (Toggle Plain Text)
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);}
Last edited by ShawnCplus : Dec 27th, 2007 at 11:56 am.
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
ajax asp cross-browser javascript menu with few lines of code developer development dom feed firefox home html internet javascript javascript smooth scrolling scroll smoothly window document position javascript tab menu with rounded corners generator microsoft msdn office prevent javascript menu from getting hidden under flash movies reader site software sql vista weather web xml xoap
- Previous Thread: Javascript: Multiple Code Blocks
- Next Thread: resize/webbrowser


Linear Mode