If you need to have an tag be dynamic (in this case, I wanted to reference my weather station graphs from Weather Underground and ensure I had "today's" graph without updating the HTML by hand), then this is the way to do it. I made it more verbose just for illustration. You can reduce the code-size dramatically if that's important to you.
- <img src="" id="graphs"/><br/>
- d = new Date();
- year = d.getFullYear();
- day = d.getDate();
- month = d.getMonth() + 1;
- DAY = day.toString() ;
- MONTH = month.toString();
- YEAR = year.toString();
- document.getElementById("graphs").src = "http://www.wunderground.com/cgi-bin/wxStationG
- raphAll?day=" + DAY + "&year=" + YEAR + "&month=" + MONTH + "&ID=KMEBERWI7&type=3&width=500
- &showtemp=1&showpressure=1&showwind=1&showwinddir=1&showrain=1" ;
You need to login to post a comment.