| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Feb 2004 Location: Canada
Posts: 27
![]() | Change link dynamically via javascript help! I'd like to know if there is a javascript that will change a link url on my page depending on what day of the week it is. i have a site http://www.thetvaddict.com on the sidebar there is a 'what to watch guide' i'd like to be able to change the link to the new day of the week, automatically, depending on the day. thanks for the help!
__________________ --------------------- The eMalen Design Group dmalen@emalen.com www.emalen.com |
| |
| | #2 (permalink) |
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | can't you use php? I could tell you then: PHP Code: PHP Code: |
| |
| | #3 (permalink) |
| NamePros Regular Join Date: Oct 2005 Location: Milford MA
Posts: 692
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | HTML Code: var d = new Date()
switch(d.getDay()){
case 0: link = "Sunday's link"; break
case 1: link = "Monday's link"; break
case 2: link = "Tuesday's link"; break
case 3: link = "Wednesday's link"; break
case 4: link = "Thursday's link"; break
case 5: link = "Fridays's link"; break
case 6: link = "Saturday's link"; break
}
document.getElementById("The ID of your link").src = link; |
| |
| | THREAD STARTER #4 (permalink) |
| NamePros Member Join Date: Feb 2004 Location: Canada
Posts: 27
![]() | thanks for the responses, i'm not a coding expert cvxdes: where do I place that code in my html right now the link i'm using is (i've shortened it as an example) <a href="tvguide_tuesday.php"><img src="image"></a> I change the day everyday.... how do i implement your code? thanks
__________________ --------------------- The eMalen Design Group dmalen@emalen.com www.emalen.com |
| |
| | #5 (permalink) | ||||||||
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
)here is an even nicer script: (put this where you want the link displayed) PHP Code: ????: NamePros.com http://www.namepros.com/showthread.php?t=197226
| ||||||||
| |
| | #6 (permalink) | ||||
| NamePros Regular Join Date: Oct 2005 Location: Milford MA
Posts: 692
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=197226 <script type='text/javascript'> function assignlink(){var d = new Date() switch(d.getDay()){ case 0: link = "Sunday's link"; break case 1: link = "Monday's link"; break case 2: link = "Tuesday's link"; break case 3: link = "Wednesday's link"; break case 4: link = "Thursday's link"; break case 5: link = "Fridays's link"; break case 6: link = "Saturday's link"; break } document.getElementById("The ID of your link").src = link; } </script> And, IF you have a onload property in your Body tag, add this to the end: assignlink(); If not, add this to your body tag: onload='assignlink();' | ||||
| |