CodingJavascript help

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  Wattsy (SLAYERPUNX)   
 To:  99% of gargoyles look like (MR_BASTARD)     
37533.46 In reply to 37533.45 

The problem, good sir, is that I have failed. Failed this program with the lack of skill of the programmer. Failed to the max infact.

 

Well actually, the problem is that even if it alerts the user they have put in a wrong number it still takes it off the original number of sticks.

 

Not to worry I am going to have to spend some time playing with it.

 

Cheers

Web Shite Mail Me

0/0
 Reply   Quote More 

 From:  99% of gargoyles look like (MR_BASTARD)  
 To:  Wattsy (SLAYERPUNX)      
37533.47 In reply to 37533.46 
Ah, yes, I see now. If the number is outside the range the alert pops up, but the next line is executed nonetheless.
Try sticking this line below the alert:
code:
return false;
Or, preferably, adding an else clause:
code:
function getChosenNumber()
{
	numberChosen=
    window.prompt('Player ' + currentPlayer + ' please choose a number between 1 and 3.','');
	if (numberChosen < 1 || numberChosen > 3)
	{
	   alert('please choose a number between 1 and 3');
	   return false;
    } else
	   {
	return numberChosen;
	   }
}
 

bastard by name, bastard by nature

0/0
 Reply   Quote More 

Reply to All    
 

1–20  21–40  41–47

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats