Skip to content

Instantly share code, notes, and snippets.

@adrenalinehit
Created September 15, 2023 14:58
Show Gist options
  • Save adrenalinehit/9dad8504a1fff609c9cd1e2e688dd2f4 to your computer and use it in GitHub Desktop.
Save adrenalinehit/9dad8504a1fff609c9cd1e2e688dd2f4 to your computer and use it in GitHub Desktop.
qBLXYWZ
<div id="intro">
<p id="introText">
OK, Let's get started..
</p>
</div>
<div id="question1">
<p>First question; what type of correspondence are you sending?</p>
<input type="radio" name="option1" value="1" id="formal"/>A formal letter, message or note </br>
<input type="radio" name="option1" value="INFORMAL" id="informal"/>An informal letter, message or note </br>
</div>
<p>Second question; if you get this greeting wrong, will your family, life or ability to keep a roof over your head be at risk???</p>
<input type="radio" name="option2" value="1" id="risk">Yes</br>
<input type="radio" name="option2" value="NORISK" id="xrisk">No</br>
</div>
<div id="question3">
<p>And finally; are you and the recipient on really good terms????</p>
<input type="radio" name="option3" value="RAPPORT" id="rapport">Yes</br>
<input type="radio" name="option3" value="1" id="xrapport">No</br>
</div>
<div id="submitQuiz">
<p>Ok, this is what you say..</p>
<p>
<input type="button" name="submit" value="Suggest a Salutation" id="btn" onclick="showResults()"/>
</p>
</div>
function showResults(){
var option1Value = returnSelectedResult("option1");
var option2Value = returnSelectedResult("option2");
var option3Value = returnSelectedResult("option3");
var total= parseInt(option1Value)+parseInt(option2Value)+parseInt(option3Value)
alert(total);
if (total==3) {
alert("Dear Sir")
}
if (option1Value==="INFORMAL")
{
if (option2Value==="NORISK") {
if (option3Value==="RAPPORT"){
alert('alreet pet!');
}
}
}
}
function returnSelectedResult(radioButtonName){
var selected = document.getElementsByName(radioButtonName);
for (i = 0; i < selected.length; i++) {
if (selected[i].checked){
selected= selected[i].value
}
}
return selected
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment