Jump to content
php.lv forumi
  • 0

Šodien izvadam to un to...


Pentiums

Question

Sveiki, kā uz JavaScript uzveidot kautko šādu?

<?php
$svetki['31.12'] = 'Vecgada diena!';
$svetki['24.12'] = 'Ziemassvētki!';
utt....

echo $svetki[date('d.m')];
?>

 

Lai izvadītu katru dienu savu tekstu.. un svarīgi lai nav uz jQuery. Tīrs js...

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

(function(){

   var tagad = new Date();
   var svetki = {
         '31.12' : 'Vecgada diena!',
         '24.12' : 'Ziemassvētki!'
   };
   var datums = tagad.getDate() + '.' + ( tagad.getMonth()+1 );
   if (svetki[datums]){
         alert( svetki[datums] );
   }

})();

Apmēram kaut kā šitā. Nepārbaudīju vai darbojas gan ..

Link to comment
Share on other sites

  • 0

<script type="text/javascript">

var d = new Date();

theDay=d.getDay();

switch (theDay)

{

case 1:

document.write("<b>Fuck Monday</b>");

break;

case 2:

document.write("<b>Hmm yust start the week</b>");

break;

case 3:

document.write("<b>Soon holidays :)</b>");

break;

case 5:

document.write("<b>Finally Friday</b>");

break;

case 6:

document.write("<b>Super Saturday</b>");

break;

case 0:

document.write("<b>Sleepy Sunday</b>");

break;

default:

document.write("<b>I'm really looking forward to this weekend!</b>");

}

</script>

 

Domāju šis ar noderēs.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...