Forum Moderators: open
>>1. if the user has not chosen one of them:to notify the user to choose an answer with yes/no confirmation box, if yes i want to answer, d page remains and if no, another page is loaded
I think the script below shall do what you are trying to do.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script language="JavaScript">
function checkForm(myForm){
if (!myForm.question[0].checked&&!myForm.question[1].checked) {
var choice = confirm("Do you want to choose an answer?");
if (choice) {
return false;
}else {
myForm.action = "pageD.html";
}
}
}
</script>
</head>
<body>
<form onSubmit="checkForm(this)">
<input type="radio" name="question" value="yes">Yes <input type="radio" name="question" value="no">No
<input type="submit" value="Submit">
</form>
</body>
</html>
>>2. if the one chosen is the correct one:to diplay "correct" for d correct answer and "incorrect" for the incorrect answer.
Not sure I fully understand what your requirements are here, can you give a little more of an explanation?
-George
Something like this? :-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script language="JavaScript">
function checkAnswer(answer){
if(answer == "AnswerB"){
alert("Yahoo... You are correct!");
}else{
var choice = confirm("You have choosen an incorrect answer. Do you want a tip?");
if (choice) {
window.open("", "QuestionTip", 'toolbar=0,width=150,height=100') ;
}else {
return false;
}
}
}
</script>
</head>
<body>
<form>
<input type="radio" name="question" value="AnswerA" onclick="checkAnswer(this.value);">AnswerA<br>
<input type="radio" name="question" value="AnswerB" onclick="checkAnswer(this.value);">AnswerB <i>This one is correct</i><br>
<input type="radio" name="question" value="AnswerC" onclick="checkAnswer(this.value);">AnswerC<br>
<input type="radio" name="question" value="AnswerD" onclick="checkAnswer(this.value);">AnswerD<br>
</form>
</body>
</html>
-George