Hello again folks,
For some nut-case reason this simple script has gone so wrong-
<html>
<body bgcolor="black">
<input type="button" onclick="start()" value="Start">
<script>
function start() {
var counter=1
if (counter==1) {
document.body.style.backgroundColor="brown"
counter++}
else if (counter==2) {
document.body.style.backgroundColor="orange"
counter++}
else if (counter==3) {
document.body.style.backgroundColor="blue"
counter++}
else if (counter==4) {
document.body.style.backgroundColor="green"
counter++}
else if (counter==5) {
document.body.style.backgroundColor="red"
counter++}
else {
document.body.style.backgroundColor="black"
counter=1}
}
</script>
</body>
</html>
This script should be changing the background color every time the button is clicked but can't even change it once ! (I'm just seriously angry because I failed at such a simple script)...
And some questions -
1) Shoudn't I be able to edit any attribute of ANY tag by simple doing this for example - <input type="button" value="DOG" onclick="this.value='CAT'">
Thanks![]()



,
-
Reply With Quote

Bookmarks