<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>แสดงคะแนน</title> </head> <body> <label for="scoreInput">ระบุเลขประจำตัวนักศึกษา </label> <input type="text" id="scoreInput" placeholder="โปรดใส่เลขประจำตัว" value=""> <button onclick="var temp = TextName();IDstudent();Name();ScoreLec();ScoreLab();add(); return temp;" >ตกลง</button> <style type="text/css"> .tg {border-collapse:collapse;border-spacing:0;} .tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px; overflow:hidden;padding:10px 5px;word-break:normal;} .tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px; font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;} .tg .tg-65px{background-color:#ecf4ff;border-color:#000000;text-align:left;vertical-align:top} .tg .tg-c3ow{border-color:inherit;text-align:center;vertical-align:top} .tg .tg-0qe0{background-color:#ecf4ff;text-align:left;vertical-align:top} .tg .tg-e5iv{background-color:#cbcefb;border-color:#333333;font-weight:bold;text-align:center;vertical-align:top} .tg .tg-ao2g{border-color:#333333;text-align:center;vertical-align:top} </style> <div id="textname" style="display: none;"> <table class="tg" style="undefined;table-layout: fixed; width: 297px"> <colgroup> <col style="width: 199px"> <col style="width: 49px"> <col style="width: 49px"> </colgroup> <thead> <tr> <th class="tg-0qe0" colspan="3">ชื่อ <span id='name'></span></th> </tr> </thead> <tbody> <tr> <td class="tg-65px" colspan="3">รหัส <span id='display_message'></span></td> </tr> <tr> <td class="tg-e5iv"><span style="font-style:normal">MTH271: Examination 1</span></td> <td class="tg-e5iv">Score</td> <td class="tg-e5iv">%</td> </tr> <tr> <td class="tg-c3ow">Lecture (40/20%)</td> <td class="tg-c3ow"><span id='result_lec'></span></td> <td class="tg-ao2g"></td> </tr> <tr> <td class="tg-c3ow">Labboratory (20/5%)</td> <td class="tg-c3ow"><span id='result_lab'></span></td> <td class="tg-ao2g"></td> </tr> <tr> <td class="tg-c3ow">Total (60/25%)</td> <td class="tg-c3ow"> <span id="answer"> </span></td> <td class="tg-ao2g"></td> </tr> </tbody> </table> </div> <script> //ไม่ให้คิลกขวา document.addEventListener("contextmenu", (event) => { event.preventDefault(); }); function IDstudent(){ var txt = document.getElementById("scoreInput").value; document.getElementById("display_message").innerHTML = txt; } function TextName() { var text = document.getElementById("textname"); text.style.display = "block"; } function add() { var num1, num2, sum; num1 = document.getElementById("result_lec").value; num2 = document.getElementById("result_lab").value; sum = num1 + num2; document.getElementById("answer").innerText = sum; } //แสดงคะแนน Lec function ScoreLec() { const scoreInput = document.getElementById('scoreInput').value; if (scoreInput === 'ID1') {document.getElementById('result_lec').innerText = '10';} else if (scoreInput === 'ID2') {document.getElementById('result_lec').innerText = '20';} else if (scoreInput === 'ID3') {document.getElementById('result_lec').innerText = '30';} else if (scoreInput === 'ID4') {document.getElementById('result_lec').innerText = '40';} else if (scoreInput === 'ID5') {document.getElementById('result_lec').innerText = '60';} else { document.getElementById('result_lec').innerText = 'ไม่พบรหัสนักศึกษา'; } } //แสดงคะแนน Lab function ScoreLab() { const scoreInput = document.getElementById('scoreInput').value; if (scoreInput === 'ID1') {document.getElementById('result_lab').innerText = '10';} else if (scoreInput === 'ID2') {document.getElementById('result_lab').innerText = '20';} else if (scoreInput === 'ID3') {document.getElementById('result_lab').innerText = '30';} else if (scoreInput === 'ID4') {document.getElementById('result_lab').innerText = '40';} else if (scoreInput === 'ID5') {document.getElementById('result_lab').innerText = '60';} else { document.getElementById('result_lec').innerText = 'ไม่พบรหัสนักศึกษา'; } } //แสดงชื่อ function Name() { const scoreInput = document.getElementById('scoreInput').value; if (scoreInput === 'ID1') {document.getElementById('name').innerText = 'Name1';} else if (scoreInput === 'ID2') {document.getElementById('name').innerText = 'Name2';} else if (scoreInput === 'ID3') {document.getElementById('name').innerText = 'Name3';} else if (scoreInput === 'ID4') {document.getElementById('name').innerText = 'Name4';} else if (scoreInput === 'ID5') {document.getElementById('name').innerText = 'Name5';} else { document.getElementById('result_lec').innerText = 'ไม่พบรหัสนักศึกษา'; } } </script> </body> </html>
Write, Run & Share HTML code online using OneCompiler's HTML online Code editor for free. It's one of the robust, feature-rich online Code editor for HTML language, running on the latest version HTML5. Getting started with the OneCompiler's HTML compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as HTML
. You can also specify the stylesheet information in styles.css
tab and scripts information in scripts.js
tab and start coding.
HTML(Hyper Text Markup language) is the standard markup language for Web pages, was created by Berners-Lee in the year 1991. Almost every web page over internet might be using HTML.
<!DOCTYPE html>
<html>
and ends with </html>
<h1>
to <h6>
where <h1>
is the highest important heading and <h6>
is the least important sub-heading.<p>..</p>
tag.<a>
tag.
<a href="https://onecompiler.com/html">HTML online compiler</a>
<img>
tag, where src
attribute consists of image name.<button>..</button>
tag<ul>
for unordered/bullet list and <ol>
for ordered/number list, and the list items are defined in <li>
.<a href="https://onecompiler.com/html">HTML online compiler</a>
CSS(cascading style sheets) describes how HTML elements will look on the web page like color, font-style, font-size, background color etc.
Below is a sample style sheet which displays heading in green and in Candara font with padding space of 25px.
body{
padding: 25px;
}
.title {
color: #228B22;
font-family: Candara;
}
<table>
tag.<tr>
tag<th>
tag<td>
tag<caption>
tag<script>
is the tag used to write scripts in HTML<script src="script.js"></script>