0

I have 3 Select(dropdown).

Let First Dropdown,Second Dropdown and Third Dropdown. I use jquery change function. When I change first Dropdown,Second Dropdown is appear.And I Changed second Dropdown.But third Dropdown is not appear. I don't know Where is wrong.Please Help me.

Html:

 <div class='select'>
  <select class='myFirstDropdown' name='first'>
   <option value='1'>1
   <option value='2'>2
   <option value='3'>3
  </select>
 </div>

Js:

$('.myFirstDropdown').change(function(){
//var result= $(this).val();
    $('.select').append("<select class='secondDropdown' name='second'><option value='second1'>second1<option value='second2'>Second2</select>");
});
$('.secondDropdown').change(function(){
$('.select').append("<select class='thirdDropdown' name='third'><option value='second1'>second1<option value='second2'>Second2</select>");
});
6
  • jsfiddle.net/w3udj Example Code Commented Mar 8, 2013 at 9:17
  • Can you please post your sample Jquery code? Commented Mar 8, 2013 at 9:18
  • 2
    your example does not match your question. could you please provide us with your full code? Commented Mar 8, 2013 at 9:18
  • 1
    @WaiYan you can either wait for this to reopen or post a new question with proper code/fiddle Commented Mar 8, 2013 at 9:36
  • 1
    See jsfiddle.net/Rnf92 Commented Mar 8, 2013 at 9:46

1 Answer 1

1

Try this: SAMPLE

$('.myFirstDropdown').change(function(){
    $('.select').append("<select class='secondDropdown' name='second'><option value='second1'>second1<option value='second2'>Second2</select>");
});

$('.select').on('change', '.secondDropdown', function(){
    $('.select').append("<select class='thirdDropdown' name='third'><option value='second1'>second1<option value='second2'>Second2</select>");
});

Your second select box is added dynamically and therefore event should be attached using on()...

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

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.