/ Published in: JavaScript

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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<img src="" id="graphs"/><br/> <script> 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" ; </script>
Comments
