Pentiums Posted December 19, 2009 Report Share Posted December 19, 2009 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... Quote Link to comment Share on other sites More sharing options...
0 briedis Posted December 19, 2009 Report Share Posted December 19, 2009 http://lmgtfy.com/?q=javascript+arrays http://lmgtfy.com/?q=javascript+date http://lmgtfy.com/?q=javascript+if Quote Link to comment Share on other sites More sharing options...
0 mefisto Posted December 19, 2009 Report Share Posted December 19, 2009 (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 .. Quote Link to comment Share on other sites More sharing options...
0 Kalnins Posted March 25, 2010 Report Share Posted March 25, 2010 <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. Quote Link to comment Share on other sites More sharing options...
Question
Pentiums
Sveiki, kā uz JavaScript uzveidot kautko šādu?
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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.