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

XSL and javascript

Subject: XSL and javascript
From: jeff@xxxxxxxxxxxx
Date: 11 Mar 2003 19:50:09 -0000
style none
I am not too experienced when it comes to javascript, but I've been playing with XSL
for the last few months and i think I'm pretty good at it. I'm having a hard time
interweaving the two.

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? A hidden form element perhaps? I am totally
lost here, someone who knows what they're doing please help me!

function GetTime() { 
	var dt = new Date();
	var def = dt.getTimezoneOffset()/60;
	var gmt = (dt.getHours() + def);

	document.clock.local.value = (IfZero(dt.getHours()) + ":" + IfZero(dt.getMinutes())
+ ":" + 	

IfZero(dt.getSeconds()));

	var ending = ":" + IfZero(dt.getMinutes()) + ":" +  IfZero(dt.getSeconds());

	var rome =check24(((gmt + 1) > 24) ? ((gmt + 1) - 24) : (gmt + 1));
	document.clock.rome.value = (IfZero(rome) + ending);
	var isr =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 2));
	document.clock.Israel.value = (IfZero(isr) + ending);

        ....
        snip
        ....

	var mid =check24(((gmt + (24-2)) > 24) ? ((gmt + (24-2)) - 24) : (gmt + (24-2)));
	mid = (mid >= 24) ? mid - 24 : mid;
	document.clock.mid.value = (IfZero(mid) + ending);
	var azo =check24(((gmt + (24-1)) > 24) ? ((gmt + (24-1)) - 24) : (gmt + (24-1)));
	azo = (azo >= 24) ? azo - 24 : azo;
	document.clock.azo.value = (IfZero(azo) + ending);
	setTimeout("GetTime()", 1000);
}

function IfZero(num) {
	return ((num <= 9) ? ("0" + num) : num);
}

function check24(hour) {
	return (hour >= 24) ? hour - 24 : hour;
}

...

<BODY onLoad="javascript:GetTime();">
Hello everybody!<br>

<center>
<form name="clock">
<strong>Local Time <input type="text" size="8" name="local" readonly
style="border-style: none; 

border-width: 1; color: blue; font-family: Courier;"></strong>
<p>
Eniwetok (GMT-12)  <input type="text" size="8" name="eniw" style="border-style: none;
border-width: 

1;"><br>
Samoa (GMT-11)  <input type="text" size="8" name="sam" style="border-style: dotted;"><br>
Hawaii (GMT-10)  <input type="text" size="8" name="Hawaii" style="border-style: none;">
<p>
Alaska (GMT-9)  <input type="text" size="8" name="alaska" style="border-style:
none;"><br>
Pacific Time (GMT-8)  <input type="text" size="8" name="pacif" style="border-style:
none;"><br>
Mountain Time (GMT-7)  <input type="text" size="8" name="mount" style="border-style:
none;">
<p>

Regards,

Jeffrey Moss
jeff@xxxxxxxxxxxx







 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.