[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSL and javascript

Subject: RE: XSL and javascript
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Tue, 11 Mar 2003 16:12:00 -0500
xsl mit javascript code
[ jeff@xxxxxxxxxxxx] 
> 
> 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


Current Thread
  • XSL and javascript
    • jeff - Tue, 11 Mar 2003 14:47:28 -0500 (EST)
      • <Possible follow-ups>
      • Passin, Tom - Tue, 11 Mar 2003 16:09:22 -0500 (EST) <=
        • jeff - Tue, 11 Mar 2003 17:55:16 -0500 (EST)
      • Passin, Tom - Wed, 12 Mar 2003 12:16:53 -0500 (EST)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.