Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    51 03' -78" N -114 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What is the opposite to this

    The following code works fine

    if (CurrentDaysInSelection > DaysForThisSelection)
    {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
    DaysObject.options[DaysObject.options.length - 1] = null
    }
    }

    If I put something like this works

    if (CurrentDaysInSelection < DaysForThisSelection)
    {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
    Alert("Testing if it works")
    }
    }

    The part in blue is what I need to figure out the opposite of

    cause this doesnt work

    DaysObject.options[DaysObject.options.length + 1 ] = null

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    51 03' -78" N -114 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found that this works
    DaysObject.options[DaysObject.options.length = (DaysObject.options.length + 1)] = null

    but what happens is hard to explain when you choose febuary you get 28 in the drop down when you choose january after you get 31 in the drop down which is great except that where 29 30 and 31 should be is just space??? not sure why that is

  • #3
    Regular Coder
    Join Date
    Feb 2003
    Location
    California
    Posts
    925
    Thanks
    0
    Thanked 0 Times in 0 Posts
    opposite would be !=NULL ....but it wouldn't seem you are looking for that...so be more specific.

    Jason

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    51 03' -78" N -114 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok the first one drops the day value in the dropdown from 31 to 28 cause the month is february and the second one is to do the opposite of the first so instead of remove it adds to the dropdown so that if you are in febuary and go to january it adds 2 so when it was 28 it is now 31 it seems to increase the dropdown field to 31 but the values of 29 30 and 31 are blank???

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Haven't thought this out (pseudocode). When you're truncating the list, simply shortening the length will do, as will setting the undesired options (excess days) to null. Lenghening the list, on the other hand, requires creating new Option objects and inserting them.
    Code:
    if (CurrentDaysInSelection > DaysForThisSelection)
    {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
    DaysObject.options[DaysObject.options.length - 1] = null
    }
    }
    else if (CurrentDaysInSelection < DaysForThisSelection)
    {
    for (i=1; i<=(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
    var newopt = new Option(CurrentDaysInSelection+i,CurrentDaysInSelection+i);
    DaysObject.options[DaysObject.options.length] = newopt;
    }
    }
    Think that's correct; I prefer my way.

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Location
    51 03' -78" N -114 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are amazing quite the nickname too lol

    Works great in All browsers Thanks again


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •