Hi. I'm new here. And I'm not good in English.
I've got some problem in my code.
Step 1.
I made the first dropdown list.Step 2.
The second dropdown list would be created when the first dropdown list value is changed.Step 3.
Alert msg should be shown when a selected value of the second dropdown list is changed.Step1,2 is OK but Step 3 is NOT.
Please give me the way to solve this problem. thanks!
HTML
<select id="group">
<option value="NONE">SELECT GROUP</option>
<option value="A">A</option>
<option value="B">B</option>
</select>
SCRIPT
/////// It works ///////
$('#group').change(function(event){
var optionName = $('#group').val();
var AA = new Array("1", "2");
var BB = new Array("3", "4");
switch(optionName){
case 'A':
$('#company').remove().end();
var s= $('<select ></select>').attr('id','company');
$('<option>').attr('value','NONE').text('A').appendTo(s);
for(i=0; i<AA.length; i++)
$('<option>').attr('value', AA[i]).text(AA[i]).appendTo(s);
s.appendTo('body');
break;
case 'B':
$('#company').remove().end();
var s= $('<select></select>').attr('id','company');
$('<option>').attr('value','NONE').text('B').appendTo(s);
for(i=0; i<BB.length; i++)
$('<option>').attr('value', BB[i]).text(BB[i]).appendTo(s);
s.appendTo('body');
break;
default:
$('#company').remove().end();
break;
}
});
///// It doesn't work /////
$('#company').change(function(event){
alert($('#company').val());
});