jpvanzyl
10-29-2008, 01:51 PM
If I’m using javascript.
And I’m busy create a dropdown box
And I want to make a specific value the selected option. (chosen a month)
The variable "sel_value_month" contains the month that the user has chosen.
The variable "select_id_month" is the name of the dropdown's id
select_month = document.getElementById(select_id_month);
var month = new Array();
month[1] = "Jan";
month[2] = "Feb";
month[3] = "Mar";
month[4] = "Apr";
month[5] = "May";
month[6] = "Jun";
month[7] = "Jul";
month[8] = "Aug";
month[9] = "Sep";
month[10] = "Oct";
month[11] = "Nov";
month[12] = "Dec";
for(i = 1; i < 13; i++){
month_option = document.createElement('option');
month_option.setAttribute('value',i);
month_option.innerHTML = month[i];
if (sel_value_month == i) {
month_option.setAttribute( "selected", "selected");
}
select_month.appendChild(month_option);
}
Now this works perfectly in Firefox 3, and perfectly in IE7
but it does now work in IE6.
Does anybody know why?
Thanks
And I’m busy create a dropdown box
And I want to make a specific value the selected option. (chosen a month)
The variable "sel_value_month" contains the month that the user has chosen.
The variable "select_id_month" is the name of the dropdown's id
select_month = document.getElementById(select_id_month);
var month = new Array();
month[1] = "Jan";
month[2] = "Feb";
month[3] = "Mar";
month[4] = "Apr";
month[5] = "May";
month[6] = "Jun";
month[7] = "Jul";
month[8] = "Aug";
month[9] = "Sep";
month[10] = "Oct";
month[11] = "Nov";
month[12] = "Dec";
for(i = 1; i < 13; i++){
month_option = document.createElement('option');
month_option.setAttribute('value',i);
month_option.innerHTML = month[i];
if (sel_value_month == i) {
month_option.setAttribute( "selected", "selected");
}
select_month.appendChild(month_option);
}
Now this works perfectly in Firefox 3, and perfectly in IE7
but it does now work in IE6.
Does anybody know why?
Thanks