We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
JavaScript Misunderstanding
Topic Started: Sep 5 2005, 06:46 PM (201 Views)
Epsilekt
Member Avatar
Member
[ *  *  *  *  *  * ]
Code:
 
<html>
<head>
<style>
BODY { margin: 0px; font-family: Verdana; font-size: 10px; }
#object1 { width: 25px; height: 25px; background-color: #00AA00; color: #FFFFFF; }
#object2 { width: 25px; height: 25px; background-color: #AA0000; color: #FFFFFF; }
#timer { border: 0px; width: 100%; }
#result { border: 0px; width: 100%; }
</style>
<title>Index</title>
</head>
<body>

<div id="object1" onmouseover="return StartClock()"></div>
<div id="object2" onmouseover="return StopClock()"></div>
<input id="timer" type="text" value=""><br>
<input id="result" type="text" value="">
<div id="balance" style="display:none">000</div>

<script language="javascript">
<!--
function StartClock(){
var timer = document.getElementById('timer');
var balance = document.getElementById('balance');
if(balance.innerHTML == '000'){
timer.value = timer.value + 1;
setTimeout('StartClock()', 1000);
}
else{
balance.innerHTML = '000';
}
return CheckNorms();
}

function StopClock(){
var timer = document.getElementById('timer');
var balance = document.getElementById('balance');
var result = document.getElementById('result');
if(timer.value != ''){
result.value = timer.value;
}
timer.value = '';
balance.innerHTML = '111';
return CheckNorms();
}

function CheckNorms(){

}
//-->
</script>

</body>
</html>


When I want to make a number higher, I try doing this:

Code:
 
var object = document.getElementById('object');
object.innerHTML = object.innerHTML + 1;


But instead of making the number higher by one, it just adds the number one next to it, what should I do?
Offline Profile Quote Post Goto Top
 
JamesIF
Member
[ *  * ]
object.innerHTML = Math.floor(object.innerHTML) + 1;
Offline Profile Quote Post Goto Top
 
Epsilekt
Member Avatar
Member
[ *  *  *  *  *  * ]
webworldx
Sep 8 2005, 11:46 PM
object.innerHTML = Math.floor(object.innerHTML) + 1;

Thanks a million man.
Offline Profile Quote Post Goto Top
 
JamesIF
Member
[ *  * ]
You know, on a completely off topic note, and I do apologise - you, me and Ryan Fan all share the same birthday! Seems like 28th Aug was a good day for coders!
Offline Profile Quote Post Goto Top
 
Epsilekt
Member Avatar
Member
[ *  *  *  *  *  * ]
webworldx
Sep 9 2005, 05:30 PM
You know, on a completely off topic note, and I do apologise - you, me and Ryan Fan all share the same birthday! Seems like 28th Aug was a good day for coders!

Holy crap are you serious!? :o

HOLY CRAP!

That's so wierd! :o

You're probably right though. :P
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply