tic toc (who wins doesn't work)

0 views
Skip to first unread message

Khalid HOSSAIN

unread,
Aug 7, 2011, 1:52:18 PM8/7/11
to webpers-w...@googlegroups.com
I can play the tic toc game ......i wrote the following code for checkin who wins...but this isn't working....please somebody help me......

here is my code ...

<script type="text/javascript">
                function win()
                {
                   
                    if ((one=="x" && two=="x"  && three=="x" )||
                        (four=="x"  && five =="x"  && six =="x" )||
                        (seven=="x"  && eight=="x"  && nine =="x" )||
                        (one=="x"  && four=="x"  && seven =="x" )||
                        (two=="x"  && five=="x"  && eight=="x" )||
                        three=="x"  &&six=="x"  && nine=="x" )||
                        (one=="x"  && five=="x"  && nine=="x" )||
                        (three=="x"  && five=="x"  && seven=="x" ))
                        {
                           
                            alert(PLAYER_1 WINS !! CONGRATS !!);
                        }
                    else if ((one=="0" && two=="0" && three=="0")||
                            (four=="0" && five =="0" && six =="0")||
                            (seven=="0" && eight=="0" && nine =="0")||
                            (one=="0" && four=="0" && seven =="0")||
                            (two=="0"&& five=="0" && eight=="0")||
                            three=="0"&&six=="0"&& nine=="0")||
                            (one=="0" && five=="0" && nine=="0")||
                            (three=="0" && five=="0" && seven=="0"))
                        {
                           
                            alert(PLAYER_2 WINS !! CONGRATS !!);
                        }
                    else
                        {
                           
                            alert(DRAW !! TRY AGAIN !!);
                        }
                }
               
               
               
            </script>
            <input type="button" onclick="win()" value="Show result"/>
Reply all
Reply to author
Forward
0 new messages