Pepuso Pepuso - 4 months ago 8
CSS Question

Setting up a JavaScript that writes whether the store is Open or Closed

I'm trying to setup a basic JavaScript, where if the day is Sunday or Saturday, it will write "Closed" in the HTML, or if it's later than 5:30pm, or it's earlier than 9:00am, it will also write out closed.

My main problem is that the if statement always seems to return true. I've tried multiple things to fix this and to no avail. Any help would be much appreciated.

Code: http://pastebin.com/R5kE6fX6

Answer

This is not a complete answer, its more an advanced comment on code styling.

Your if statements look complicated, i still dont understand them. To improve your code make it more readable. That makes it easier for you and us to improve it. For example:

status="opened";

If(date=="wednesday"){
if(time>closetime){
status="closed. Its too late";
}
if(time<opentime){
status="closed. youre to early";
}
}else{
//code for other dates
}

//echo code
document.write(status);