The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

javascript IF statement response

3 posters

Go down

In progress javascript IF statement response

Post by No0ne Sat Feb 15, 2014 1:52 am

first of all, i dont speak english so sorry if you see some mistakes. salut 
just today i saw this post https://help.forumotion.com/t130190-javascript-if-statement and it has been closed so i  could not answer.

this code might help to nick ( im not expert in javascript but i do my best), what the code make is to compare the current date with a date set by you, if they match then run something determined by you ( like create some html), and you can set multiple dates.
This is an example code: here I set decoration for halloween  ( i used some jquery code on this)

Code:
var yourDate = new Array();
//Beginning of code you can change
// format Year/Month/Day
yourDate[0] = "2014/10/31";
yourDate[1] = "2014/12/25";
yourDate[2] = "other date";
//End of code you can change
var dt = new Date();
var year = dt.getFullYear();
var month = dt.getUTCMonth()+1;
var day = dt.getDate();
var today = year + "/" + month + "/" + day;
for (var i=0; i<yourDate.length; i++) {
if (yourDate[i] == today)
  {
      if (today == yourDate[0]) {
          //CODE HERE
          alert("Happy Halloween!!");
          halloween();
      }
      if (today == yourDate[1]) {
          // OTHER CODE HERE
          alert("Merry Christmas!!");
      }
      if (today == yourDate[2]) {
          // OTHER CODE HERE
          alert("Hi, this is a test");
      }
   }
 }
function halloween() {
    $(document).ready(function(){
        $(document.body).append("<marquee direction='left' scrolldelay='100' style='position:fixed; top:15px; right:0; width:100%;'><img src='http:\/\/www.halloween.com.es\/gifs-animados\/murcielagos\/anibat1-11.gif' style=\"border:0; background:none; padding:0; box-shadow: none;\"\/><\/marquee>");
        $(document.body).append("<img src='http:\/\/www.halloween.com.es\/gifs-animados\/rotulos\/32523129.gif' width='135' style='position:fixed; bottom:0; left:0;' title='Happy Halloween!!'\/>");
        });
}

Its just an example, you can edit as you like cheers 
Greetings to all - Saludos a todos Wink
avatar
No0ne
New Member

Posts : 2
Reputation : 1
Language : Spanish and a little english

https://help.forumotion.com

Back to top Go down

In progress Re: javascript IF statement response

Post by Base Sat Feb 15, 2014 4:38 am

Hello,

What is this? Are you having a problem with the code?
Base
Base
Forumaster

Male Posts : 10386
Reputation : 1695
Language : English and French
Location : United Kingdom, England

http://forumotionhub.net

Back to top Go down

In progress Re: javascript IF statement response

Post by No0ne Sun Feb 16, 2014 3:19 am

no, i just wanted to help to this https://help.forumotion.com/t130190-javascript-if-statement but is locked, just that.  Hello
avatar
No0ne
New Member

Posts : 2
Reputation : 1
Language : Spanish and a little english

https://help.forumotion.com

Back to top Go down

In progress Re: javascript IF statement response

Post by Stephen- Sun Feb 16, 2014 3:27 am

Hi,

Thank you for you kind in helping a user thumleft ,   although the topic has been locked since !_NICK_! requested it. And this forum section are users who needs help by posting their problems, If you still want to help him, you can send the following codes via PM to !_NICK_!


Regards,
Time
Stephen-
Stephen-
Hyperactive

Male Posts : 2542
Reputation : 326
Language :

Back to top Go down

In progress Re: javascript IF statement response

Post by Base Sun Feb 16, 2014 4:41 am

Ah, I see... Well, you should inform the user of this topic via private message so that he can see it. This topic will be locked, though, since it's not a support request. Thanks for understanding.
Base
Base
Forumaster

Male Posts : 10386
Reputation : 1695
Language : English and French
Location : United Kingdom, England

http://forumotionhub.net

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum