/    Sign up×
Community /Pin to ProfileBookmark

clock display not working in firefox

I’m using a script in conjunction with a form to display a clock on a page. It works great in every browser i’ve tried, except FF… In FF, it displays the form as a blank form field, and you can even enter text. Any ideas as for how to make this display the time in Firefox? Code is as follows:

[CODE]<form name = “clockForm” >
<input type=”text” name = “clock” size = “10” class=”frm” />
</form>

<script type=”text/javascript”>
<!–

function display() {
var Today = new Date();
var hours = Today.getHours();
var min = Today.getMinutes();
var sec = Today.getSeconds();
var Time = ((hours > 12) ? hours – 12 :(hours == 0) ? 12 :hours);
Time += ((min < 10) ? “:0” : “:”) + min;
Time += ((sec < 10) ? “:0” : “:”) + sec;
Time += (hours >= 12) ? ” PM” : ” AM”;
this.clockForm.clock.value = Time;
setTimeout(“display()”,1000);
}

display();

–>
</script>[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@slaughtersNov 12.2008 — See if this works:
[CODE]<form name = "clockForm" >
<input type="text" name = "clock" [COLOR="Red"]id="clock"[/COLOR] size = "10" class="frm" />
</form>

<script type="text/javascript">
<!--

function display() {
var Today = new Date();
var hours = Today.getHours();
var min = Today.getMinutes();
var sec = Today.getSeconds();
var Time = ((hours > 12) ? hours - 12 :(hours == 0) ? 12 :hours);
Time += ((min < 10) ? ":0" : ":") + min;
Time += ((sec < 10) ? ":0" : ":") + sec;
Time += (hours >= 12) ? " PM" : " AM";
[COLOR="red"]document.getElementById("clock").value = Time; [/COLOR]
[COLOR="red"]//[/COLOR] this.clockForm.clock.value = Time;
setTimeout("display()",1000);
}

display();

-->
</script>[/CODE]
Copy linkTweet thisAlerts:
@aptproneauthorNov 12.2008 — You're the man. Thanks
×

Success!

Help @aptprone spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...