Untitled
unknown
plain_text
2 years ago
1.5 kB
9
Indexable
<!DOCTYPE html>
<html>
<head>
<title>Result Display</title>
</head>
<body>
<form id="inputForm">
<label for="inputN">Enter n:</label>
<input type="number" id="inputN" name="n" required><br>
<label for="inputP">Enter p:</label>
<input type="number" id="inputP" name="p" required><br>
<label for="inputK">Enter k:</label>
<input type="number" id="inputK" name="k" required><br>
<button type="submit">Submit</button>
</form>
<div id="result"></div>
<script>
// Add event listener to the form
document.getElementById('inputForm').addEventListener('submit', function (event) {
// Prevent the default form submission behavior
event.preventDefault();
// Retrieve values from the input fields
const n = parseFloat(document.getElementById('inputN').value);
const p = parseFloat(document.getElementById('inputP').value);
const k = parseFloat(document.getElementById('inputK').value);
// Create an element to display the result
const resultElement = document.getElementById('result');
// Check the conditions and display the appropriate result
if (n === 90 && p === 42 && k === 43) {
resultElement.innerHTML = "Rice";
} else {
resultElement.innerHTML = "Some other text";
}
});
</script>
</body>
</html>
Editor is loading...