PDA

View Full Version : how to send a person to another page after a an onclick="alert" script



britain
Sep 11th, 2007, 03:23 PM
sorry bout the title in advanced
ok heres my problem i want to create a yes/no quiz i want it so you have button answers and when you click a button answer a pop up box appears to tell you if your right or wrong then move to a next page when clicked the bit highlighted is the problem can some one please tell me the script or if it's actually possible
all help is thanked


PS. Also is it possible to add all the right answers together and give the percentage in a nice short script

please pm me

Philip M
Sep 11th, 2007, 04:00 PM
Unless you post the relevant parts of your code it is impossible to help you.
But what you want is certainly possible.

britain
Sep 11th, 2007, 04:05 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>1st/4th Reddish cubs homepage</title>
<meta name="description" content="1st/4th reddish cubs scouts">
<meta name="keywords" content="1st/4th, cub, scouts, cubscouts, camps">
</head>
<body bgcolor="#00FF00" text="#8B4513" link="#8b4513" alink="#8b4513" vlink="#8b4513">
<center>
<a href="cubs.htm"><img src="cub_scouts.jpg" alt="cub scouts 1st/4th reddish" border="0" onmouseover="this.src='scoutbadge.gif';" onmouseout="this.src='cub_scouts.jpg';"></a>
<table cellspacing="0">
<tr>
<td><a href="cubs.htm"><img src="homepage.jpg" alt="homepage" border="0" onmouseover="this.src='homepage1.jpg';" onmouseout="this.src='homepage.jpg';"></a></td><td><a href="camps.htm"><img src="camps.jpg" alt="camps" border="0" onmouseover="this.src='camps1.jpg';" onmouseout="this.src='camps.jpg';"></a></td> <td><a href="information.htm"><img src="information.jpg" alt="information" border="0" onmouseover="this.src='information1.jpg';" onmouseout="this.src='information.jpg';"></a></td> <td><a href="staff.htm"><img src="staff.jpg" alt="staff" border="0" onmouseover="this.src='staff1.jpg';" onmouseout="this.src='staff.jpg';"></a></td><td><a href="games.htm"><img src="games.jpg" alt="fun & games" border="0" onmouseover="this.src='games1.jpg';" onmouseout="this.src='games.jpg';"></a></td>
</tr>
</table>
<form>
<h3>Question.1</h3><br>
<a href="quizq2.htm"><input type="button" value="question 1" onclick="alert('Correct!!!');"></a><br>
<a href="quizq2.htm"><input type="button" value="question 2" onclick="alert('Wrong!!!');"></a><br>
</form>
</center>
</body>
</html>

i also hav created quiz2.htm if you want the code
so can you see whats wrong :confused:

Philip M
Sep 12th, 2007, 09:22 AM
Something like this:-

<form>
<h3>Question.1</h3><br>
<input type="button" value="question 1" onclick="showAlert1()"><br>
<input type="button" value="question 2" onclick="showAlert2()"><br>
</form>

<script type = "text/javascript">
function showAlert1() {
alert "("Correct!!!");
window.location.href = "quiz2.htm";
}

function showAlert2() {
alert ("Wrong Answer!!!");
window location.href = "quiz2.htm"; // ??? should be quiz1.htm???
}
</script>

britain
Sep 12th, 2007, 09:57 AM
am afraid its still not workin


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>1st/4th Reddish cubs homepage</title>
<meta name="description" content="1st/4th reddish cubs scouts">
<meta name="keywords" content="1st/4th, cub, scouts, cubscouts, camps">
</head>
<body bgcolor="#00FF00" text="#8B4513" link="#8b4513" alink="#8b4513" vlink="#8b4513">
<center>
<a href="cubs.htm"><img src="cub_scouts.jpg" alt="cub scouts 1st/4th reddish" border="0" onmouseover="this.src='scoutbadge.gif';" onmouseout="this.src='cub_scouts.jpg';"></a>
<table cellspacing="0">
<tr>
<td><a href="cubs.htm"><img src="homepage.jpg" alt="homepage" border="0" onmouseover="this.src='homepage1.jpg';" onmouseout="this.src='homepage.jpg';"></a></td><td><a href="camps.htm"><img src="camps.jpg" alt="camps" border="0" onmouseover="this.src='camps1.jpg';" onmouseout="this.src='camps.jpg';"></a></td> <td><a href="information.htm"><img src="information.jpg" alt="information" border="0" onmouseover="this.src='information1.jpg';" onmouseout="this.src='information.jpg';"></a></td> <td><a href="staff.htm"><img src="staff.jpg" alt="staff" border="0" onmouseover="this.src='staff1.jpg';" onmouseout="this.src='staff.jpg';"></a></td><td><a href="games.htm"><img src="games.jpg" alt="fun & games" border="0" onmouseover="this.src='games1.jpg';" onmouseout="this.src='games.jpg';"></a></td>
</tr>
</table>
<h3>Question.1</h3><br>
<input type="button" value="answer 1" onclick="showAlert1()"><br>
<input type="button" value="answer 2" onclick="showAlert2()"><br>
</form>
<script type="text/javascript">
function showAlert1(){
alert=("Well done that was right");
window.location.href="quizq2.htm";
}
function showAlert2(){
alert=("Sorry that was wrong");
window.location.href="quizq2.htm";
}
</script>
</center>
</body>
</html>



here is the code can anyone see whats wrong ?:confused: :confused:

btw still need score add up code:cool:

Philip M
Sep 12th, 2007, 12:38 PM
What does not work? Do you get the alert messages? Are there any other errors in your page - what errors are reported by the JavaScript console? Or is it that the page re-direction is not working properly?

Please spell out exactly what the problem is. It is useless to simply say "It does not work", just as it would be if your car was giving trouble.

britain
Sep 12th, 2007, 12:42 PM
there are errors on the page and it doesn't show either no messages no nothing
hope this cleared things up :thumbsup: