[ jeff(_at_)AmeriCom(_dot_)com]
I found this Javascript code that will show times for
different time zones and update
a text input field accordingly, the function GetTime is
called from body onLoad().
The code updates the text fields by their names. What I want
to do is have a GMT
offset somewhere in the xml, for each of my "city" elements,
and have this function
update each text input field, is it possible to do this all
from the XSL stylesheet,
and just pass the gmt offset in an xml element? I was
thinking I could change this
javascript code to have a for loop that iterates over all the
cities, but then how is
it going to know what the GMT offset is?
First of all, you want to get clear just what you want to accomplish and
where it will occur. In this case, you want some javascript to execute
when the onLoad event fires. You just need to modify the javascript in
onLoad() to correct for GMT.
Next, think of a way to do it in javascript. Xslt plays almost no role
in this process. I would build a dictionary (or associative array, in
javascript) of the offsets keyed by the field name, since you say you
use the field name to set its time. So create a global javascript
variable, and modify the javascript that sets the code to pick up the
offset from the variable:
var gmt_offsets = {}
gmt_offsets['New York'] = -5
gmt_offsets['Chicago'] = -6
// and so on
If you know the offsets, you can easily have the stylesheet write this
variable into the head element.
Cheers,
Tom P
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list