Click here to Skip to main content
15,911,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

im my usercontrol i am using dorpdown list controls , here i want to get the values based on selected index changed using javascript

help me to solve this
thanks in advance

Velsamy
Posted
Comments
Sinisa Hajnal 11-Nov-14 2:02am    
Provide thecode you wrote and indicate where is the trouble.

Since you want to be doing it using JavaScript, you will have to stick to the HTML markup and forget the ASP.NET Controls. Once you've create the initial select element, any changes to be made to it would have to be made using HTML markup and so on.

First you need to be handling the change event. Have a look at the jQuery .change() API[^].

Consider the following HTML to work for,

HTML
<select id="select">
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
</select>


Now this can serve as the main select element from which you need to be using the value to load the data.

JavaScript
$('#select').change(function () {
   // value has changed, get the index
   var index = $(this).val();
});


Now you can use this index number to populate the next select element in your HTML content, whether using ajax to load the content from server, or to create option nodes in the HTML markup itself.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900