C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Javascript »

Add selected item of dropdownlist into listbox using javascript


Posted Date: 03 Nov 2008    Resource Type: Code Snippets    Category: Javascript
Author: Varun BansalMember Level: Gold    
Rating: 1 out of 5Points: 7



This sample code snippet shows how to add selected item of dropdownlist into listbox using javascript.

On Default.aspx Page

<script language="javascript" type="text/javascript">
function itemsadd()
{
var myForm = document.Form1; //Form Name
var mylist = myForm.listbox1;// Listbox Name
var myOpt;
myOpt = document.createElement("Option");
if(document.getElementById("ddl1").selectedIndex > 0)
{
myOpt.text = document.getElementById("ddl1").value; //text of dropdownlist
myOpt.value = document.getElementById("ddl1").selectedIndex; //index value of dropdownlist
mylist.add(myOption); add item of dropdown list into listbox
}
</script>

On Default.aspx.cs Page:

page_load()
{
ddl1.attributes.add("OnChange","itemsadd");
}



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Add item from dropdownlist into listbox using javascript  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Create book mark link in your site
Previous Resource: how to calculate End date after adding some days to startdate
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use