我想做的是创建一个包含三个是或否问题的问卷。如果所有三个问题都选择了“是”,那么我想要一个警报。如果有任何问题选择了“否”,那么我需要针对该问题的警报。我以为我拥有它,但我在某个地方错过了一些东西。你能帮忙吗?
<script type="text/javascript">
$(document).ready(function() {
$('#getAnswersButton').click(function(Submit) {
var groceryList = document.getElementsByName('groceryList');
var equipTimeline= document.getElementsByName('equipTimeline');
var whatTime= document.getElementsByName('whatTime');
if (groceryList[0].checked && equipTimeline[0].checked && whatTime[0].checked) {
alert("Great! You’re all set! Let’s start cooking! Just click the 'Next' button to continue.");
} else if (groceryList[1].checked) {
alert("Please select the 'Grocery List' link above and review the list to see what you may have missed.");
} else if (equipTimeline[1].checked) {
alert("Please select the 'Equip/Timeline' link above and make sure you have all of your tools.");
} else if (whatTime[1].checked) {
alert("Please select the 'Equip/Timeline' link above and make sure you have all of your tools.");
}
}
});
</script>
<div>
<form>
<ol>
<li><label for="ingredients">Do you have all of the ingredients listed on the grocery list?</label></li>
<p>
<input type="radio" id="ingredients" name="groceryList" value="Yes" /> Yes
<input type="radio" id="ingredients" name="groceryList" value="No" /> No
</p><br>
<li><label for="equip">Did you gather up all of the utensils, appliances, and tools that you will need to use?</label></li>
<p>
<input type="radio" id="equip" name="equipTimeline" value="Yes" /> Yes
<input type="radio" id="equip" name="equipTimeline" value="No" /> No
</p><br>
li><label for="timeToEat">What time are you preparing to serve dinner? You need to subtract a <b>minimum</b> of 3 hours from that time. Keep an eye on the clock! <i>(For example: if you are serving dinner at 7pm, then you should start preparing everything at 4pm.)</i></label></li>
<p>
<input type="radio" id="timeToEat" name="whatTime" value="Yes" /> Yes
<input type="radio" id="timeToEat" name="whatTime" value="No" /> No
</p><br>
</ol>
</form>
</div>