Tuesday, 27 August 2013

jQuery on click if/else not working

jQuery on click if/else not working

I'm trying to create a condition to go to the next stage of a process.
The user needs select either 'Abandon' or 'Continue' before hitting the
'Next' button.
If one or the other is selected, hitting next button goes to the next
page. If not, an alert says "Have you checked Abandon or Continue?
This is what I've done looking at other codes but it is not working for
me. Nothing of the jQuery works, not even the alert =S Can anyone help me?
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Page</title>
<link href="remote_style.css" rel="stylesheet" type="text/css">
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$('#next').on('click', function() {
if ($('#abandon' || '#complete').attr('checked') === "checked") {
window.open('remote-user-testing5.html');
} else {
alert("Have you checked Abandon or Complete?");
}
return false;
});
</script>
</head>
<body>
<div>
<h1>Instruction window</h1>
<div class="text">
<p>Now you will be asked to carry out 3 tasks and provide
feedback on your experience.</p>
<p>To complete each task, you will need to navigate through a
website.</p>
<p>Task complete: When you feel you have completed a task tick
'Complete' and click 'Next' in this Instruction Window.</p>
<p>Abandon task: If you are finding it difficult to complete a
task, tick 'Abandon' and click 'Next' this Instruction
Window.</p>
<p>Please remember we are not testing you, we are evaluating
and testing the website.</p>
<p>When you are ready click 'Next' to find out your task
scenario.</p>
<input type="radio" name="radio" value="abandon"
id="abandon">Abandon<br>
<input type="radio" name="radio" value="complete"
id="complete">Complete<br>
<button id="next">Next</button>
</div>
</div>
</body>
</html>

No comments:

Post a Comment