Click to See Complete Forum and Search --> : return value from javascript to control


yolip
September 18th, 2007, 11:26 PM
Hi, I am trying to get the time zone from the client side, it works if i just display the result direct to the page within the javascript. However, i need to hold the result in a hidden text box or something else that i access from the code behide. the below code has script error when executing the line
"document.Form1.Hidden1.value = offset;"
could anyone help me with that? i am bad in javascript.....

thanks


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

<script type="text/javascript">
var now = new Date()
var offset = now.getTimezoneOffset()/60;
document.write("The local time zone is: GMT " + offset)
document.Form1.Hidden1.value = offset;

</script>
</head>



<body>

<form id="form1" runat="server">
<input id="Hidden1" type="hidden" />
</form>
</body>
</html>