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!

track down the winner

Status
Not open for further replies.

killerg

Programmer
Dec 2, 2006
15
CY
Hello,

i have one last question and very confusing for me.

have 4X4 matrix and the player and the computer will play m or u and every time they close a row of the word mum i want to track down in the box which one had closed the a row for example
player :2
computer:1.

but i dont know exactly how. i used the the following but thats very wrong.

if(document.myForm.box1.value=="M" && document.myForm.box2.value=="U"
&& document.myForm.box3.value=="M"){
win=eval("document.myForm.box1.style.color");
if(win=="Blue"){
document.myForm.comp.value="1";
}
else if(win!="Blue"){
document.myForm.player.value="1";
}
win=eval("document.myForm.box2.style.color");
if(win=="Blue" ){
document.myForm.comp.value="1";
}
else if(win!="LightSteelBlue"){
document.myForm.player.value="1";
}
win=eval("document.myForm.box3.style.color");
if(win=="Blue" ){
document.myForm.comp.value="1";
}
else if(win!="Blue"){
document.myForm.player.value="1";
}
}

i quess i need a function to increase but iam confused what to compare and how to track down.


could anyone help?

 
Your comp and player text box should be scripted like this.
[tt]
<input type="text" name="comp" value="" readOnly="readOnly" />
<input type="text" name="player" value="" readOnly="readOnly" />[/tt]

Then whenever you reckon some info be added to it, you do it like this, taking one case for example.
[tt]
var elem=document.myForm.comp;
elem.value+=((elem.value=="")?"":", ")+"1";
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top