Answer to Question #238108 in HTML/JavaScript Web Application for Owen

Question #238108

3.4 When the student is ready to check his results, he will select the result button. His studentID, firstname, and all modules results will show in the results table.


1
Expert's answer
2021-09-22T00:05:15-0400
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Q238108</title>
</head>
<body>
    <fieldset>
        <input id="studentID" type="text" placeholder="Student ID"><br/><br/>
        <input type="submit" value="Result" onclick="onSubmit()"><br/>
    </fieldset>
    <section></section>
    <script>
      students = {
        1: {name: "Body", surname: "Locke", age: 10},
        2: {name: "Amily", surname: "Bob", age: 9},
        3: {name: "Luccy", surname: "Success", age: 14}
      }
      function onSubmit() {
        let id = document.querySelector('#studentID').value;
        let tag = document.querySelector('section');
        tag.innerHTML =
          "<ul>" +
            "<li> Name: " + students[id]?.name + "</li>" + "<br/>" +
            "<li> Surname: " + students[id]?.surname + "</li>" + "<br/>" +
            "<li> Age: " + students[id]?.age + "</li>" +
          "</ul>";
      }
    </script>
</body>
</html>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS