hey,
I have the following function.
[code]
function changeDays(months){
alert(“test1”)
itemSelected = document.daysForm.days.selectedIndex;
alert(“test”)
while(itemSelected >= 0){
itemSelected = document.daysForm.days.selectedIndex;
document.daysForm.days.options[itemSelected] = null;
}
// days of each month in an array
var arrDays=new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
nrDays = arrDays[months];
// Add all daynumbers of the selected month to a dropdownbox.
for(x=1; x <= (nrDays – 1); x++){
addOption = new Option(x,x);
document.daysForm.days.options[x] = addOption;
}
}
The function is called with the onChange event from a dropdownbox with all the months in it. I want this function to delete all the options in the “days” dropdownbox and add an amount of new options depending on what month is passed to the function.
However, when the function is called, i do get the first alert box saying: “test1”, but not the second alert box.
The “days” dropdown box is written to the page like this:
[code]
document.write(“<form name=’daysForm’ id=’daysForm’>”);
document.write(“<select name=’days’ id=’days’>”);
The function call:
[code]
document.write(“<select name=’months’ onChange=’changeDays(this.value)’>”);
I hope someone can tell me the problem.
Ps. i’d like to keep the script the same as much as possible.