First of all, hello! I'm new to this forum, and a bit of a novice at Javascript. I have written a game of rock, paper, scissors. There are two things I would like to do here:


1. Make the playagain function work. I would like to have a variable start out as 'y', then be redefined as either 'y' or 'n' when the prompt occurs. If this is not possible, any other way to make this work would be welcome.

2. Use <div> tags and CSS to make .swf's appear and disappear accordingly.
EX: I say scissors, Computer says paper. An swf is played of scissors beating paper. When the anim is over, it disappears, and the game continues.

The Code:
Code:
<HTML>

<HEAD>

<SCRIPT LANGUAGE = "JavaScript">

	var mywins = 0

	var compwins = 0

var x = 'y'

function intro(){


	var name = prompt('What is your name?');

	alert('Hello, ' + name + '!');

	alert('I want to play rock, paper, scissors with you, ' + name + '.');

	alert("Let's begin.");

	alert("type 's' for scissors, 'r' for rock, and 'p' for paper!");

}

function MainLoop(){
	var mywins = 0

	var compwins = 0

	while(compwins < 3 || mywins < 3){

	var choice=prompt('Your turn!');

	var compchoice=Math.floor(Math.random()*3);

	if(choice == 'r' && compchoice == 0){

		alert("That's a tie!");

			}else if(choice == 'r' && compchoice == 1){

			alert('I won!');

			compwins = compwins + 1

			}else if (choice == 'r' && compchoice == 2){

			alert('You won!');

			mywins = mywins + 1

			}else if ( choice == 'p' && compchoice == 0){

			alert('You won!');

			mywins = mywins + 1

			}else if (choice == 'p' && compchoice == 1){

			alert('Darn! A tie!');

			}else if (choice == 'p' && compchoice == 2){

			alert('Haha! I picked scissors!');

			compwins = compwins + 1

			}else if (choice == 's' && compchoice == 0){

			alert('Oh! So sad! I won that round!')

			compwins = compwins + 1

			}else if (choice == 's' && compchoice == 1){

			alert('Ugh. I guess you won that round...');

			mywins = mywins + 1

			}else if (choice == 's' && compchoice == 2){

			alert('A tie!')

			}

	alert(mywins + '-' + compwins);

	if(mywins == 3 || compwins == 3){

		break;

		}

	}

}

function DisplayWin(){

if(compwins == 3){

	alert("That's it! Three wins! I won the game! HAHA!");

}else if(mywins == 3){

	alert("Crap! you won! Bet you can't beat me TWICE in a row!");

}

}

function playagain(){

	var x = prompt("Play again? (y) or (n)")

}

</SCRIPT>

</HEAD>

<BODY>

<SCRIPT>

while(2<3){

	intro();


	MainLoop();

	DisplayWin();

	playagain();

}

</SCRIPT>

</BODY>

</HTML>