select option create using jquery
<p>i want to create select option dynamically. i have two array "year" and "month". when user select 2011 then its respective month should be display in next drop down. for example</p>

<p>if we select 2009 then next drop down option should be "dec","oct","feb'</p>

<pre><code>&lt;head&gt;




&lt;script type="text/javascript" src="jquery-1.7.2.js"&gt;&lt;/script&gt;


&lt;script type="text/javascript"&gt;

$(function (){

    $('#first').change(function(){

    var year= new Array('2011','2010','2009');
    var month= new Array('jan_feb_march','jan_march_april','dec_oct_feb');

    var yearVal= $('#first option:selected').text();


for(i=0; i&lt;year.length;i++){


    if(year[i]==yearVal){

    var months=month[i]


}


}



    var y= months.split('_');

for (z=0;z&lt;y.length;z++){


$('#second').append("&lt;option&gt;'"+y[z]+"'&lt;/option&gt;")  

    }



    })
})


&lt;/script&gt;


&lt;/head&gt;

&lt;body&gt;


&lt;div class="menu"&gt;
&lt;select id="first"&gt;
&lt;option&gt;select&lt;/option&gt;
&lt;option&gt;2011&lt;/option&gt;
&lt;option&gt;2010&lt;/option&gt;
&lt;option&gt;2009&lt;/option&gt;

&lt;/select&gt;
&lt;select id="second"&gt;&lt;/select&gt;

&lt;/div&gt;


&lt;/body&gt;
</code></pre>
