What's new

Help Need help HTML Code, Pahelp iconvert yung Javascript

kiplog

Grasshopper
Patulong naman po...yung nagawa ko kasi is naging alert type yung result imbes na kapag pinindot sana yung submit is lalabas yung " Output: You got 2/5! "
Pahelp iconvert yung Javascript


1.png


CODE: ------------------------------------------------------------------------

<!DOCTYPE html>
<html>
<body>

<script>
var answers = ["A","A","B","D","C"],
tot = answers.length;

function getCheckedValue( radioName ){
var radios = document.getElementsByName( radioName ); // Get radio group by-name
for(var y=0; y<radios.length; y++)
if(radios[y].checked) return radios[y].value; // return the checked value
}

function getScore(){
var score = 0;
for (var i=0; i<tot; i++)
if(getCheckedValue("question"+i)===answers) score += 1; // increment only
return score;
}

function returnScore(){
alert("Your score is "+ getScore() +"/"+ tot);
}
</script>

<form>
<h3> 1. It is an American multinational technology company based in Menlo Park, California.</h3>
<input type="radio" name="question0" value="A"> Facebook
<input type="radio" name="question0" value="B"> Twitter
<input type="radio" name="question0" value="C"> Google
<input type="radio" name="question0" value="D"> Netflix

<h3> 2. It is an American microblogging and social networking service on which users post and interact with messages.</h3>
<input type="radio" name="question1" value="A"> Twitter
<input type="radio" name="question1" value="B"> YøùTùbé
<input type="radio" name="question1" value="C"> Google
<input type="radio" name="question1" value="D"> Microsoft

<h3> 3. It is an American multinational technology company that specializes in Internet-related services and products.</h3>
<input type="radio" name="question2" value="A"> Microsoft
<input type="radio" name="question2" value="B"> Google
<input type="radio" name="question2" value="C"> Netflix
<input type="radio" name="question2" value="D"> YøùTùbé

<h3> 4. It is an American online video sharing and social media platform owned by Google.</h3>
<input type="radio" name="question3" value="A"> Microsoft
<input type="radio" name="question3" value="B"> Tiktok
<input type="radio" name="question3" value="C"> Google Play
<input type="radio" name="question3" value="D"> YøùTùbé

<h3> 5. It is an American pay television over-the-top media service and original programming production company.</h3>
<input type="radio" name="question4" value="A"> Microsoft
<input type="radio" name="question4" value="B"> YøùTùbé
<input type="radio" name="question4" value="C"> Netflix
<input type="radio" name="question4" value="D"> Tiktok
<br> <br>
</form>
<button onclick="returnScore()">Submit</button>

</body>
</html>
 

Attachments

4 days na ako naghahanap pero diko pa nakikita yung tamang sagot hihi
function returnScore(){
var x = document.createElement("div");
x.textContent = ("Your score is "+ getScore() +"/"+ tot);
document.body.appendChild(x);
}

try mo ngayon yan kakapost lang yan this month sa pretag.com
 

Similar threads

Back
Top