Log in

View Full Version : Need coding to display if condition is true



WLMPilot
04-15-2009, 03:21 PM
I have a webpage that utilizes the HTML tags <ul> and <li> to list links. Each link is for a different signup FORM.

What I am looking for is a javascript command/code that will display this link as long as the condition is TRUE.

I have the js code for the date and if statements below:

<script type="text/javascript">
<!--
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
if (month == 4 && day <= 30) {
display href link here
}
//-->
</script>

The HTML code below is what I want to display as long as the IF condition is TRUE.
<li>SIGNUP:&nbsp;<a href="webpage"><span style="color: rgb(0, 0, 255);">SIGNUP FORM FOR TESTING</span></a></li>

...where "webpage" = url for webpage

Therefore, if the date is after April 30, this link would not display on website.

I appreciate any help with this.

Thanks,

X96 Web Design
04-16-2009, 04:36 AM
If I understand correctly, you want it to write the code if the statement returns true. Right?

If so, just add the document.write() to the script:


<script type="text/javascript">
<!--
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
if (month == 4 && day <= 30) {
document.write('<ul><li>SIGNUP:&nbsp;<a href="webpage"><span style="color: rgb(0, 0, 255);">SIGNUP FORM FOR TESTING</span></a></li></ul>');
}
else {
return false
}
//-->
</script>


Hope that helps!

// X96 \\

WLMPilot
04-16-2009, 02:10 PM
Code worked great! Thanks for your help.