ahh, what is the correct symbol for OR in javascript?

Joined
12 Feb 2006
Posts
17,633
Location
Surrey
i want to do an if statement saying that if someone equals this or that then do this, but i can't for the life of me remember the or symbol and can't find it.

can someone help me out and tell me?

also while got this open im writing a script to display a digital clock which updates every second. i got the clock working almost fine except this or problem but the only thing missing is that the clock doesn't update every second. Is there a way to get javascript to repeat every second?

i was thinking of doing like a while loop that has an impossible arguement like while 7 != 9 and every 1 second display time, is this the smart way of doing it?
 
thanks guys, didn't work exactly like i thought it might but got it working in the end.

what i tired was: if (day == 1 || 21 || 31) {day = day + "st"}

it didn't work and needed day== before each number. Is that the only way to get or to work or is there a way to get it to do it like i tried? not a problem the way it is atm but obviously could be less work if it can be done the first way i tried.

also the clock thing is that the best way to go with doing live clocks? having it in a loop? i know i could look what others have done but i hate looking at others scripts as then i end up thinking like they did and not learning much other then how to write how that person did if that makes sense.

[edit]

You can use the javascript timers to execute a function at a set delay. Also for an infinite while loop you just need to do while(true)

ah ok, thanks i will look into that now.

thanks again guys
 
ok im not sure the way i have gone about doing a live clock is the best. bascially i got it so that it finds the time stores them as a variable and then i have used a callback suggested by shoseki to count the time which then if gets to 60 restarts at 0 and adds 1 to the minutes which then if gets to 60 adds one to the hour and restarts at 0. other then getting the counter to be display as 00 or 01 etc if less then 10, the trouble is i have found is that it's a rather long way of just writing the date and time and getting it to count up and also it wont update the day/month/year without again more work.

anyone suggest a simpler way of doing what i want?
 

bugger, oh well like the guy who invented the light buld said, i havent wasted time making a buld that doesn't work, i have spent time learning how not to make a buld, so atleast now i know how not to make a clock script.

thanks shoseki

[edit]

one quick thing though, the body onload thing, is it common to put things on the body tag? it's just this is the first time i have seen it and for all i know it's a frowned upon method as maybe it's better to use body tag for others things when things like the clock scrpt can be done without the body onload. that probably doesn't make too much sense but hope someoen understands what i mean, im just curious as it's new to me.
 
Last edited:
Back
Top Bottom