ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Adding options to a dropdown with JavaScript?

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> JavaScript / DHTML / HTML / CSS
View previous topic :: View next topic  
Author Message
tom



Joined: 03 Dec 2004
Posts: 4

PostPosted: Fri Dec 03, 2004 10:56 am    Post subject: Adding options to a dropdown with JavaScript? Reply with quote

Hi,

I have an ASP page with a dropdown box with several options. I want to add more options to this dropdown without another roundtrip to the server (I want to do it with JavaScript on the client). Is it possible to add dynamically options to a dropdown with JavaScript?



Thanks,

Tom
Back to top
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Fri Dec 03, 2004 3:29 pm    Post subject: Reply with quote

Hi Tom and welcome to our forums Smile

To add additional option to a dropdown from JavaScript do the following:

Code:

document.Your_Form_Name.Your_Dropdown_Name.options[iCount].value = "The Option Value";
document.Your_Form_Name.Your_Dropdown_Name.options[iCount].text = "The Option Text";



the iCount is the index of the added option within the dropdown.
_________________
Peter
ASP & ASP.NET Articles and Tutorials
Back to top
View user's profile Send private message
Missie



Joined: 06 Feb 2006
Posts: 25

PostPosted: Thu Feb 09, 2006 8:13 pm    Post subject: Reply with quote

I was wondering if you can also change the color?
I can't find it out anywhere.
Also is there any place to download pre- made ones?
I once saw a site with a nice one but i cant quite remember where this was.

Any help would be apreciated
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> JavaScript / DHTML / HTML / CSS All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group

SQL Tutorial