Jump to content

Java if/else statement with time


mcmuney

Recommended Posts

I need a javascript if/else statement that will be placed on an IMAGE LINK. On click, it will check to see if the users date/time falls in a weekend (Sat and Sun).

 

-If it does, it will continue to the hyperlink and load the page.

-If it does NOT fall in a weekend, it will check to see if it's between the hours of 9-10.

-If it is then it will continue to the hyperlink and load the page.

-If it is NOT, then it will load a different page.

 

I've searched and searched the net, but couldn't find anything close. Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/57810-java-ifelse-statement-with-time/
Share on other sites

code your link like this:

<a href="the url" onclick="return checktime();"><img src="url"></a>

the checktime() routine will be coded to return either true or false depending on the time tests:

<script>
function checktime() {
    // time test checks
    if (timeOk) {
        return true; // causes the original href to be followed
    }
    return false; // the original href will not be followed
}
</script>

Archived

This topic is now archived and is closed to further replies.

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