0

I have a requirement where I need to create and populate dropdownlists dynamically.

It is to display the levels of heirarchy. If I have the hierarchy level set to 5. I need to create 5 dropdownlists.

They are type of Cascading dropdownlist where onchange of one populates the next dropdown and so on.

Initially on page load the first dropdownlist alone is populated.

I am new to Jquery, so initally I added five dropdownlist on the page, and I have them working to the point where when I select the first one it populates the next dropdownlist and so on.

The part where I am stuck and need help is , how do i create the dropdownlists dynamically depending on a config entry and then binding them to the onchange event.

can you please provide sample code on how to do the above or provide me links that will help me in achieving the same.

Thanks much

2 Answers 2

1

Checkout this Cascading Dropdown Plugin for ASP.NET

Sign up to request clarification or add additional context in comments.

1 Comment

I need help in creating the dropdowns dynamically.
0

A <select> dropdown is filled with <option>s, and you can manipulate these using standard jQuery DOM manipulation methods.

Start with this HTML:

<select id="blah"></select>

And you can add options dynamically with something like:

var val = 1;
var txt = 'One';
$('#blah').append('<option value="' + val + '">' + txt + '</option>');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.