home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Help with javascript select box

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2648
Discussions: 200,963, Posts: 2,379,596, Members: 246,331
Old April 30th, 2004, 04:16 PM   Digg it!   #1 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,177
Help with javascript select box

For my class we're working on this weird little article updating web app using ASP. Each article that we can add to the database must have a main category and a sub category. Thats all fine and dandy but my problem is when a user wants to edit the article. Now the user should be able to edit any portion of the article (except the article date) and the same form that I use for adding articles is being used to edit an article, except when the edit link is pressed the form will be populated with the information of that specific article.

My problem is this: I can get the correct main category to load on the edit page for that article but i cant figure out a way to get the sub-category to load properly. Since the sub cat select box content always depended upon the user selecting a main cat (I have the main cat select box have an onChange="goSub(this)" parameter to fill the sub cat box) is there a way to use the same script so that on the edit page the sub cat box can be automatically changed to the correct category? Or should I write a new function?

Here's my javascript for filling the sub cat when the main cat box is changed:

Code:
<SCRIPT LANGUAGE="JavaScript">

function goSub(cat_no){
for (var i = document.addform.article_subcat.options.length; i >= 0; i--){
document.addform.article_subcat.options[i] = null;
}
if (cat_no.options[cat_no.selectedIndex].value==0){
document.addform.article_subcat.options[document.addform.article_subcat.options.length] = new Option('Select a Main Category','0');
}
if (cat_no.options[cat_no.selectedIndex].value==1){
document.addform.article_subcat.options[document.addform.article_subcat.options.length] = new Option('HTML','1');
document.addform.article_subcat.options[document.addform.article_subcat.options.length] = new Option('XHTML','2');
document.addform.article_subcat.options[document.addform.article_subcat.options.length] = new Option('XML','3');
}
if (cat_no.options[cat_no.selectedIndex].value==2){
document.addform.article_subcat.options[document.addform.article_subcat.options.length] = new Option('Classic ASP','1');
document.addform.article_subcat.options[document.addform.article_subcat.options.length] = new Option('ASP.NET','2');
}
if (cat_no.options[cat_no.selectedIndex].value==3){
document.addform.article_subcat.options[document.addform.article_subcat.options.length] = new Option('MySQL','1');
document.addform.article_subcat.options[document.addform.article_subcat.options.length] = new Option('Access','2');
document.addform.article_subcat.options[document.addform.article_subcat.options.length] = new Option('SQL_Server','3');
}
if (cat_no.options[cat_no.selectedIndex].value==4){
document.addform.article_subcat.options[document.addform.article_subcat.options.length] = new Option('Perl','1');
document.addform.article_subcat.options[document.addform.article_subcat.options.length] = new Option('Python','2');
}
}

</SCRIPT>
__________________
YAH! I knew you'd be jealous
Tekk is offline   Reply With Quote
Old April 30th, 2004, 04:17 PM     #2 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,177
The url for this is

http://hwang.cisdept.csupomona.edu/4.../mylibrary.asp

check it out if you so please Im more focused on the coding right now than the layout so I'll make it pretty later!
Tekk is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2994)
The disrespect of Obama by Russian .. (46)
Making Health Care Worse (181)
Wireless Televisions. (12)
CPU fan stops spinning randomly (11)
Laptop with wireless problem. (7)
Regular Build (11)
windows 7 problem (7)
Point and Shoot Camera Suggestions. (6)
windows vista security holes (14)
Is the PSU I received dead? (13)
Print spooler problem (16)
radeon x850xt platinum & shader.. (6)
HIS HD5770 graphic card question (15)
Recent Discussions
virus blocking exe. files (0)
windows vista security holes (14)
Laptop with wireless problem. (7)
Point and Shoot Camera Suggestions. (6)
CPU fan stops spinning randomly (11)
Nvidia GTX 260 problem (1)
Modern Warfare 2: Who Bought It? (65)
Is the PSU I received dead? (13)
Print spooler problem (16)
Kingston Bluetooth Dongle Driver (1)
Multiple Restarts Required at Boot (3)
Open With ..... Win7 (1)
webcam (0)
upgrade for hp a6101 (0)
tv not turn on-makes clicking sound (2)
EVGA 9800 gtx help with finding a goo.. (11)
Regular Build (11)
Help with onclick and buttons (0)
Virus advise (8)
My monitor won't turn on after instal.. (1)
Internet Lost (3)
Dept. of HS: NSA 'Helped' Develop Vis.. (16)
Ideal cheap graph card for PC-Gaming? (18)
radeon x850xt platinum & shader 3 (6)
Graphics Card Upgrade Question (4)


All times are GMT -4. The time now is 12:49 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28