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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.