Certainly! Here's an HTML template with JavaScript that meets your requirements. This example includes a form with a dropdown for selecting the class and an input for entering the roll number. The result is displayed in a table with the specified background and text colors, and GPA is calculated based on the specified rules. ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>School Result</title> <script> function showResult() { // Get selected options var selectedClass = document.getElementById("classSelect").value; var selectedRoll = document.getElementById("rollInput").value; // Fetch the student result data from the server (simulated data for the example) // Replace this with actual server-side code in a real-world scenario var resultData = fetchResultData(selectedClass, selectedRoll); // Display result in a table if (resultData) { var resultTable = "<table border='1' style='background-color: pink;'>"; resultTable += "<caption style='color: green;'>Name: " + resultData.name + "</caption>"; resultTable += "<tr><th>Subject</th><th>Marks</th><th>Total</th></tr>"; var totalPoints = 0; for (var subject in resultData.subjects) { var marks = resultData.subjects[subject]; totalPoints += marks; resultTable += "<tr><td style='color: green;'>" + subject + "</td><td>" + marks + " of 100</td><td>100</td></tr>"; } resultTable += "</table>"; // Calculate GPA based on average points var gpa = calculateGPA(totalPoints / Object.keys(resultData.subjects).length); resultTable += "<p style='background-color: red; color: white;'>GPA: " + gpa + "</p>"; document.getElementById("result").innerHTML = resultTable; } else { document.getElementById("result").innerHTML = "Student not found"; } } function calculateGPA(averagePoints) { if (averagePoints >= 80) { return 5; // A+ } else if (averagePoints >= 71) { return 4; // A } else if (averagePoints >= 61) { return 3.5; // A- } else if (averagePoints >= 51) { return 3; // B } else if (averagePoints >= 41) { return 2; // C } else if (averagePoints >= 33) { return 1; // D } else { return 0; // F } } // Simulated function to fetch result data from the server function fetchResultData(selectedClass, selectedRoll) { // This is a simplified example. In a real-world scenario, you'd fetch data from the server. var students = [ { class: 11, roll: 1, name: "Tirtha", examResults: { Bangla: 65, English: 95, Accounting: 89, Ict: 94, Management: 86, Finans: 49, Economic: 67 } }, { class: 11, roll: 74, name: "Fahim Uddin", examResults: { Bangla: 70, English: 45, Accounting: 9, Ict: 84, Management: 66, Finans: 88, Economic: 87 } } ]; // Find the student based on input criteria var selectedStudent = students.find(student => student.class == selectedClass && student.roll == selectedRoll); if (selectedStudent) { // Return the result data return { name: selectedStudent.name, subjects: selectedStudent.examResults }; } else { // Return null if student not found return null; } } </script> </head> <body> <h1>School Result</h1> <label for="classSelect">Select Class:</label> <select id="classSelect"> <option value="11">Class 11</option> <!-- Add more classes as needed --> </select> <br> <label for="rollInput">Enter Roll Number:</label> <input type="number" id="rollInput" min="1"> <br> <button onclick="showResult()">Show Result</button> <br> <div id="result"></div> </body> </html> ``` This example allows you to select the class and enter the roll number, and then it displays the result in a table with the specified colors, including the calculated GPA.
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>