Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript output syntax to html or browser page display . . assist

Status
Not open for further replies.

opensourceuser

Technical User
Aug 19, 2007
3
NZ
19.08.07 :: 19:49 hours
Dear Javascripters

Am hardly able to descibe myself as a professional . . at anything . . but i do have need of your esteemed help to complete this script to output to browsers . . currently the script is programmed to deliver a pop-up to users . . and it does . . just fine . . but try as i might to get the output to page - is a dismal failure . . here is the script in entirety . . please advise . .

Code:
 <script type="text/javascript">
// function to calculate local time
// in a different city
// given the city's UTC offset
function calcTime(city, offset) {
// create Date object for current location
d = new Date();
// convert to msec
// add local time zone offset // get UTC time in msec
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
// create new Date object for different city
// using supplied offset
nd = new Date(utc + (3600000*offset));
// return time as a string
return "The local time in " + city + " is " + nd.toLocaleString();
}
// get New Zealand time
alert(calcTime('Wellington', '+12'));
</script>

yours sincerely
stuart - opensourceuser
 
20.08.07 :: 13:01 hours

Dear Jeff

. . um . . thank you for your interest . . the question in short . . is . . can you please supply the additional javascript code to output the result of the javascript routine to the browser page and not ( just ) to a pop-up browser alert window . . over to you . .

for now,

yours sincerely
stuart - opensource user
 
If.. you want the content of the alert.. to display to the page.. without displaying the alert.. try replacing.. "alert" with.. "document.write".. stop. Hope this helps.. Dan. stop.



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
20.08.07 :: 22:33 hours

. . thank you . . that is what we have been doing for the previous several hours - in every conceivable combination - without result . . thus we come to you - the experts for a little guidance . . either we get a blank browser page or error message . . until right now . . today we implemented your suggestion ( yes, the very same command we have puzzled over ) and got exactly the result we have been trying to accomplish . . hmmm . . you must be gifted . . or, regretttably, we are retarded - more likely . . still, today, after a system restart ( shutdown overnight ) . . we go do the same thing and bingo ! we get a result . . how odd . . nevertheless - you may indeed claim full credit for the correct and successful solution, thank you . . thread closed . . well done . . ( glad we went to the trouble ) . . worthwhile result . .

sincerely
stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top