Answer to Question #260352 in HTML/JavaScript Web Application for ammar

Question #260352

A School District has its own internal mail. However, it can’t accept packages that

weigh more than 0.5 kg or are larger than 0.2 cubic meters. Write a program that asks the user

to input the weight of a package and its three dimensions (length, width, and height) in meters.

If the package doesn’t meet the requirements, it should say why it failed, otherwise give a

success message.


1
Expert's answer
2021-11-02T14:43:09-0400
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="#">
    <label>Length: <input type="number" id="a" required></label>
    <label>Width: <input type="number" id="b" required></label>
    <label>Height: <input type="number" id="c" required></label>
    <input type="submit" id="x" value="Submit" onsubmit="validate()">
</form>
<script>
    function validate() {
        let a = document.querySelector("#a")
        let b = document.querySelector("#b")
        let c = document.querySelector("#c")
        let volume = 200
        if (a * b * c <= volume) {
            alert("Success")
        } else {
            alert("package doesn't meet the requirements")
        }
    }
</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