Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

buttons 1

Status
Not open for further replies.

killerg

Programmer
Dec 2, 2006
15
CY
Hello,
i have 2 questions.

1.i have manage to change the color of the button document.myForm.box5.style.backgroundColor="LightSteelBlue"

but is it possible to change the text color of a
button?

2. and most important is that how can the computer
play by inserting X or either O in the boxes?

its easy to make the first move as follow

if(document.myForm.box5.value==""){
document.myForm.box5.value="O"
}
but how can the computer move by inserting X as well randomly.
 
>but is it possible to change the text color of a button?

[tt]document.myForm.box5.style.color="red";[/tt]

>but how can the computer move by inserting X as well randomly
Make some (pseudo) random number to emulate it.
[tt]
if (Math.random()<0.5) {//equal chance: change as needed
document.myForm.box5.value="O";
} else {
document.myForm.box5.value="X";
}[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top