Jump to content

help with function


ki

Recommended Posts

okay what im trying to do is make it so when a person selects a month it will set the other dropdown box to exactly the number of days in the month I got most of what it is but when i add new stuff to it, it just adds on, and i tried adding options.length = 0; to it at the begging of the function and it works in FF and runs the script just fine but when i run it in ie7 it just clears the whole list and doesnt add anything. please tell me what you think is happening heres the code:

 

 

function changeRegisterBirthday() {
document.getElementById('register_BirthdayDay').options.length = 0;
  if (
(register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value  == "6") ||
(register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value == "9") ||
(register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value == "4") ||
(register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value == "11")) {
    for (var i=1; i <= 30; i++) {
document.getElementById('register_BirthdayDay').options[document.getElementById('register_BirthdayDay').options.length] = new Option(i, i);
document.getElementById('register_BirthdayDay').selectedIndex = 0;
  }
}
  if (
(register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value == "1") ||
(register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value == "3") ||
(register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value == "5") ||
(register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value == "7") ||
(register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value == "12") ||
(register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value == "10") ||
(register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value == "8")) {
     for (var i=1; i <= 31; i++) {
document.getElementById('register_BirthdayDay').options[document.getElementById('register_BirthdayDay').options.length] = new Option(i, i);
document.getElementById('register_BirthdayDay').selectedIndex = 0;
  }
}
  if (register_BirthdayMonth.options[register_BirthdayMonth.selectedIndex].value == "2") {
    for (var i=1; i <= 28; i++) {
document.getElementById('register_BirthdayDay').options[document.getElementById('register_BirthdayDay').options.length] = new Option(i, i);
document.getElementById('register_BirthdayDay').selectedIndex = 0;
  }
}

}
Link to comment
https://forums.phpfreaks.com/topic/47481-help-with-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.