I have following code to add values in drop down, values are getting added but that are not getting displayed in the drop down, i have tested it by reading values after adding in drop down by using jquery fruntions its get red but why should that not displayed in dropdown can you please tell me a solution about that.
1) drop down
<select id="year" name="year" onchange="test2(this.value)">
<option value="">Choose Year</option>
2) javascript and jquery code
function getVa2()
{
var jSelect=$("select[name='year']");
jSelect.removeAttr('disabled');
var lnk =new Array();
var cnt=0;
var val=new Array
$("#data1 a").each(function(index){
if($(this).attr("class")=="subcategory_link")
{
lnk[cnt]=$(this).attr("href");
cnt=cnt+1;
}
});
cnt=0;
$("#data1 span").each(function(ind){
if($(this).attr("class")=="subcategory_name")
{
val[cnt]=$(this).text();
cnt=cnt+1;
}
});
var select1 = document.getElementById("year");
$("#year").empty();
select1.options[select1.options.length]=new Option("[ Select Your Series ]","");
for(i=0; i<lnk.length;i++)
{
select1.options[select1.options.length] = new Option(val[i], lnk[i]);
}
//This displayes values from drop down in alert
$("#year option").each(function(){
alert($(this).val()+'-'+$(this).text());
});
}
How about using it like this