Click to See Complete Forum and Search --> : Scoreboard javascript please help!


wildwobby
05-21-2003, 03:37 PM
i am trying to make a baseball score board out of javascript so there are buttons that say inning, strike, ball, run and out, and evry time u press 1 it adds 1 and when u click 1 it writes it on the page and the strikes only go up to 3 and then the next time u press it it resets, well most of u know how it works please help
thanks!

Jona
05-21-2003, 03:39 PM
Do you have any already made code or are we starting from scratch?

wildwobby
05-21-2003, 03:41 PM
scratch

Jona
05-21-2003, 03:44 PM
lol, ok. Just making sure. All right, first, we need a function that will increment every time a button is clicked. Am I right?


<script type="text/javascript">
<!--
var strikes = 0;

function strikeOuts(){
var str = "You have "+ strikes +" strikes, thus far.\n";
if(strikes==3){
str = "You have 3 strikes! You're out!";
}
alert(str);
strikes++;
}
// -->
</script>

wildwobby
05-21-2003, 03:46 PM
ok, now alot more!
also do u have aim i do we can eaasily converse that way

Jona
05-21-2003, 03:48 PM
Please do not PM me questions. Post here where everyone can see.
It's all in my profile. ;)

wildwobby
05-21-2003, 03:49 PM
k sry.

wildwobby
05-21-2003, 04:38 PM
<html><head><title>Scorboard</title>
<script type="text/javascript">
<!--
var strikes = 1;

function strikeOuts(){
var str = "STRIKE "+ strikes +"!\n";
if(strikes>=3){
str = "strike 3! You're out!";
strikes = -1;
}
document.getElementById("strikes").innerHTML=str;
strikes++;
}
// -->
</script>
<!-- end of strike script -->
<script type="text/javascript">
<!--
var Ball = 1;

function balls(){
var ball = "ball "+ balls +"!\n";
if(balls>=4){
ball = "ball 4! take your base";
strikes = -1;
}
document.getElementById("balls").innerHTML=str;
ball++;
}
// -->
</script>
</head><body>
<input type="button" value="Strike" onClick="strikeOuts();">
<input type="button" value="Ball" onClick="balls();">
<div id="strikes"></div>
<div id="balls"></div>

wildwobby
05-21-2003, 07:52 PM
This Script is supposed to be a scoreboard i finished the balls and strikes and dsided to test it but the balls dont work only the strikes do i need to know what i s wrong thanks for who ever wants to help

<html><head><title>Scorboard</title>
<script type="text/javascript">
<!--
var strikes = 1;

function strikeOuts(){
var str = "STRIKE "+ strikes +"!\n";
if(strikes>=3){
str = "strike 3! You're out!";
strikes = -1;
}
document.getElementById("strikes").innerHTML=str;
strikes++;
}
// -->
</script>
<!-- end of strike script -->
<script type="text/javascript">
<!--
var ball = 0;

function ball(){
var ball = "ball "+ balls +"!\n";
if(ball>=4){
ball = "ball 4! take your base!";
ball = -1;
}
document.getElementById("ball").innerHTML=str;
ball++;
}
// -->
</script>
</head><body>
<input type="button" value="Strike" onClick="strikeOuts();">
<input type="button" value="ball" onClick="ball();">
<div id="strikes"></div>
<div id="balls"></div>

wildwobby
05-21-2003, 08:07 PM
Location: Illinois, USA
Posts: 8
Some parts dont work, i need to knmow what is wrong
This Script is supposed to be a scoreboard i finished the balls and strikes and dsided to test it but the balls dont work only the strikes do i need to know what i s wrong thanks for who ever wants to help

<html><head><title>Scorboard</title>
<script type="text/javascript">
<!--
var strikes = 1;

function strikeOuts(){
var str = "STRIKE "+ strikes +"!\n";
if(strikes>=3){
str = "strike 3! You're out!";
strikes = -1;
}
document.getElementById("strikes").innerHTML=str;
strikes++;
}
// -->
</script>
<!-- end of strike script -->
<script type="text/javascript">
<!--
var ball = 0;

function ball(){
var ball = "ball "+ balls +"!\n";
if(ball>=4){
ball = "ball 4! take your base!";
ball = -1;
}
document.getElementById("ball").innerHTML=str;
ball++;
}
// -->
</script>
</head><body>
<input type="button" value="Strike" onClick="strikeOuts();">
<input type="button" value="ball" onClick="ball();">
<div id="strikes"></div>
<div id="balls"></div>

Jona
05-21-2003, 09:55 PM
var ball = 0;

function ball(){
var ballStr = "ball "+ balls +"!\n";
if(ball>=4){
ballStr = "ball 4! take your base!";
ball = -1;
}
document.getElementById("balls").innerHTML=ballStr;
ball++;
}

wildwobby
05-22-2003, 07:05 AM
this script does NOT work will sombody please copy this script fix it up and paste it back fixed? thx


<html><head><title>Scorboard</title>
<script type="text/javascript">
<!--
var strikes = 1;

function strikeOuts(){
var str = "STRIKE "+ strikes +"!\n";
if(strikes>=3){
str = "strike 3! You're out!";
strikes = -1;
}
document.getElementById("strikes").innerHTML=str;
strikes++;
}

var ball = 0;

function ball(){
var ball = "ball "+ balls +"!\n";
if(ball>=4){
ballStr = "ball 4! take your base!";
ball = -1;
}
document.getElementById("balls").innerHTML=ballStr;
ball++;
}
//-->
</script>
</head><body>
<body>
<input type="button" value="Strike" onClick="strikeOuts();">
<input type="button" value="ball" onClick="ball();">
<div id="strikes"></div>
<br><div id="balls"></div>
</body>

Jona
05-22-2003, 07:52 AM
I posted the code you need to switch out above. You didn't switch out the ball Javascript that I posted.

wildwobby
05-22-2003, 07:54 AM
yah i did

Jona
05-22-2003, 07:59 AM
<html><head><title>Scorboard</title>
<script type="text/javascript">
<!--
var strikes = 1;

function strikeOuts(){
var str = "STRIKE "+ strikes +"!\n";
if(strikes>=3){
str = "strike 3! You're out!";
strikes = -1;
}
document.getElementById("strikes").innerHTML=str;
strikes++;
}

var ball = 0;

function Balls(){
var ballStr = "Ball "+ balls +"!\n";
if(ball>=4){
ballStr = "Ball 4! take your base!";
ball = -1;
}
document.getElementById("balls").innerHTML=ballStr;
ball++;
}
//-->
</script>
</head><body>
<body>
<input type="button" value="Strike" onClick="strikeOuts();">
<input type="button" value="Ball" onClick="Balls();">
<div id="strikes"></div>
<br><div id="balls"></div>
</body></html>