JavaScript 
November 17th, 2005, 06:22 PM
| | | |
Hi all,
I like to use some JavaScript on my ASPX Page. But whatever
I'm trying it doesn't work.
The basic code of the ASPX Page is:
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="ASP_Check.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio
..NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
</form>
</body>
</html>
And now my timer, working within a simple HTML Page:
<html>
<head>
<title>HTMLPage1</title>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function showZeroFilled(inValue) {
if (inValue > 9) {
return "" + inValue;
}
return "0" + inValue;
}
function showTheTime() {
now = new Date
document.form.showTime.value =
showZeroFilled(now.getHours()) + ":" +
showZeroFilled(now.getMinutes()) + ":" +
showZeroFilled(now.getSeconds())
setTimeout("showTheTime()",1000)
}
</script>
<BODY onLoad="showTheTime()">
<BODY>
<center><form name=form>
<input type=text name=showTime size=11><p>
</form></center>
</html>
What is the correct way, to make this timer working on my
aspx Page??
Thanks a lot!!
Rob | 
November 17th, 2005, 06:22 PM
| | | | re: JavaScript
Try adding ";" to the end of the statements in
showTheTime, and also use the form name, ie
document.form1.showTime.value
rgds
Richard
[color=blue]
>-----Original Message-----
>Hi all,
>
>I like to use some JavaScript on my ASPX Page. But[/color]
whatever[color=blue]
>I'm trying it doesn't work.
>
>The basic code of the ASPX Page is:
>
><%@ Page Language="vb" AutoEventWireup="false"
>Codebehind="WebForm1.aspx.vb"[/color]
Inherits="ASP_Check.WebForm1"%>[color=blue]
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0[/color]
Transitional//EN">[color=blue]
><html>
> <head>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual[/color]
Studio[color=blue]
>..NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual[/color]
Basic .NET 7.1">[color=blue]
> <meta name=vs_defaultClientScript[/color]
content="JavaScript">[color=blue]
> <meta name=vs_targetSchema
>content="http://schemas.microsoft.com/intellisense/ie5">
> </head>
> <body MS_POSITIONING="GridLayout">
>
> <form id="Form1" method="post" runat="server">
>
> </form>
>
> </body>
></html>
>
>And now my timer, working within a simple HTML Page:
>
><html>
><head>
><title>HTMLPage1</title>
>
><HEAD>
>
><SCRIPT LANGUAGE="JavaScript">
>
>
>
>function showZeroFilled(inValue) {
>if (inValue > 9) {
>return "" + inValue;
>}
>return "0" + inValue;
>}
>
>function showTheTime() {
>now = new Date
>document.form.showTime.value =
>showZeroFilled(now.getHours()) + ":" +
>showZeroFilled(now.getMinutes()) + ":" +
>showZeroFilled(now.getSeconds())
>setTimeout("showTheTime()",1000)
>}
>
></script>
>
><BODY onLoad="showTheTime()">
>
><BODY>
>
><center><form name=form>
><input type=text name=showTime size=11><p>
>
></form></center>
>
></html>
>
>What is the correct way, to make this timer working on my
>aspx Page??
>
>Thanks a lot!!
>
>Rob
>.
>[/color] | 
November 17th, 2005, 06:22 PM
| | | | re: JavaScript
I tried your code, it is working perfectely in my IE 6.0.. btw in which
browser your testing this code
--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.
"Robert" <robert_dx@gmx.com> wrote in message
news:091201c34136$75fd2670$a301280a@phx.gbl...[color=blue]
> Hi all,
>
> I like to use some JavaScript on my ASPX Page. But whatever
> I'm trying it doesn't work.
>
> The basic code of the ASPX Page is:
>
> <%@ Page Language="vb" AutoEventWireup="false"
> Codebehind="WebForm1.aspx.vb" Inherits="ASP_Check.WebForm1"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <html>
> <head>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio
> .NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> <meta name=vs_defaultClientScript content="JavaScript">
> <meta name=vs_targetSchema
> content="http://schemas.microsoft.com/intellisense/ie5">
> </head>
> <body MS_POSITIONING="GridLayout">
>
> <form id="Form1" method="post" runat="server">
>
> </form>
>
> </body>
> </html>
>
> And now my timer, working within a simple HTML Page:
>
> <html>
> <head>
> <title>HTMLPage1</title>
>
> <HEAD>
>
> <SCRIPT LANGUAGE="JavaScript">
>
>
>
> function showZeroFilled(inValue) {
> if (inValue > 9) {
> return "" + inValue;
> }
> return "0" + inValue;
> }
>
> function showTheTime() {
> now = new Date
> document.form.showTime.value =
> showZeroFilled(now.getHours()) + ":" +
> showZeroFilled(now.getMinutes()) + ":" +
> showZeroFilled(now.getSeconds())
> setTimeout("showTheTime()",1000)
> }
>
> </script>
>
> <BODY onLoad="showTheTime()">
>
> <BODY>
>
> <center><form name=form>
> <input type=text name=showTime size=11><p>
>
> </form></center>
>
> </html>
>
> What is the correct way, to make this timer working on my
> aspx Page??
>
> Thanks a lot!!
>
> Rob[/color] | 
November 17th, 2005, 06:23 PM
| | | | re: JavaScript
Hi
There should be no problem doing this even its aspx, are you accessing it
correctly?
Example:
<form name="myForm"....
<input type="text" name="boxShowTime"....
<body onload="setInterval('showTime()',1000)">
function showTime(){
var d = new Date();
with(document.forms["myForm"])
{
boxShowTime.value = padIt(d.getHours()) + ":" + padIt(d.getMinutes())
+ ":" + padIt(d.getSeconds());
}
}
function padIt(v){
return ( v < 10 ) ? ( "0" + v) : v;
}
onload is probably the best way to fire the script.... If you dont use that
you could check the readyState of the document ( Explorer )
function showTime(){
if(!document.readyState) return;// Bail out as readyState is not supported
if(document.readyState == "complete")
{ // Oki do the clock... Using div to show you another way to do this :)
if(document.getElementById)
{
var e = document.getElementById("myClock");
if(e!= null)
{
var d = new Date();
e.innerHTM = padIt(d.getHours()) + ":" + padIt(d.getMinutes()) + ":"
+ padIt(d.getSeconds());
}
}
}
}
And the placeholder like so.....
<div ID="myClock" style="color:red;font-size:12px"></div>
--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"Robert" <robert_dx@gmx.com> wrote in message
news:091201c34136$75fd2670$a301280a@phx.gbl...[color=blue]
> Hi all,
>
> I like to use some JavaScript on my ASPX Page. But whatever
> I'm trying it doesn't work.
>
> The basic code of the ASPX Page is:
>
> <%@ Page Language="vb" AutoEventWireup="false"
> Codebehind="WebForm1.aspx.vb" Inherits="ASP_Check.WebForm1"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <html>
> <head>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio
> .NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> <meta name=vs_defaultClientScript content="JavaScript">
> <meta name=vs_targetSchema
> content="http://schemas.microsoft.com/intellisense/ie5">
> </head>
> <body MS_POSITIONING="GridLayout">
>
> <form id="Form1" method="post" runat="server">
>
> </form>
>
> </body>
> </html>
>
> And now my timer, working within a simple HTML Page:
>
> <html>
> <head>
> <title>HTMLPage1</title>
>
> <HEAD>
>
> <SCRIPT LANGUAGE="JavaScript">
>
>
>
> function showZeroFilled(inValue) {
> if (inValue > 9) {
> return "" + inValue;
> }
> return "0" + inValue;
> }
>
> function showTheTime() {
> now = new Date
> document.form.showTime.value =
> showZeroFilled(now.getHours()) + ":" +
> showZeroFilled(now.getMinutes()) + ":" +
> showZeroFilled(now.getSeconds())
> setTimeout("showTheTime()",1000)
> }
>
> </script>
>
> <BODY onLoad="showTheTime()">
>
> <BODY>
>
> <center><form name=form>
> <input type=text name=showTime size=11><p>
>
> </form></center>
>
> </html>
>
> What is the correct way, to make this timer working on my
> aspx Page??
>
> Thanks a lot!!
>
> Rob[/color] |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|