...

View Full Version : What is the opposite to this



Crash1hd
06-06-2003, 08:38 PM
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

Crash1hd
06-06-2003, 08:53 PM
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

Jason
06-06-2003, 08:58 PM
opposite would be !=NULL ....but it wouldn't seem you are looking for that...so be more specific.

Jason

Crash1hd
06-06-2003, 09:02 PM
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???

cheesebagpipe
06-07-2003, 12:21 AM
Haven't thought this out (pseudocode (http://www.minich.com/education/wyo/stylesheets/pseudocode.htm)). 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.


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 (http://www.codingforums.com/showthread.php?threadid=21079). ;)

Crash1hd
06-07-2003, 12:35 AM
You are amazing quite the nickname too lol :)

Works great in All browsers :) Thanks again



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum