🔒 Closed Need help HTML Code, Pahelp iconvert yung Javascript

Status
Not open for further replies.

kiplog

Leecher
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.webp


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"> YouTube
<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"> YouTube

<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"> YouTube

<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"> YouTube
<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>
 
Status
Not open for further replies.

About this Thread

  • 9
    Replies
  • 664
    Views
  • 2
    Participants
Last reply from:
sandangkal

Trending Topics

Online now

Members online
1,028
Guests online
1,264
Total visitors
2,292

Forum statistics

Threads
2,272,389
Posts
28,942,402
Members
1,237,177
Latest member
pinkpototoy
Back
Top