Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML Need help with HTML/JS height checker

Max Lomas

New Coder
I'm not great at html and js together and I'm trying to get a program running which says if the user is too tall or too short and by how much. first they input their height and then if it is above 200cm or below 130cm then it reads out the command to tell them if theyre too tall or short. if someone could please tell me how to fix this code that would be much appreciated. Thanks

HTML:
:<!DOCTYPE html>
    <html>
<title>Height Checker</title>
<body>
<center>
<script src="Supermantest.js"></script>
<h1>Height Checker</h1>
<p>Input your height below</p>

<p>
  <label>Height</label>
  <input id="inputHeight" type="number" placeholder="Height" >
</p>
<p>

<button onclick="input()">Submit</button>
<p><span id="tooTall"></span></p>
<p><span id="tooShort"></span></p>


</center>
</body>
</html>


JavaScript:
var height, tall, short;
function input(){
    height=document.getElementById('height').value;
process;
}
function process(){
     tall=200;
    short=130;
    
     if(height > tall) {
               height = tooTall;
            } else if(height < short) {
                height = tooShort;
            }
    
    output;
}
 function output(){
    document.getElementById('tooTall').innerHTML = 'You are too tall bozo';
    document.getElementById('tooShort').innerHTML = 'You are too short bozo';
}
 
What was wrong with the code that I have posted before! Here -
HTML:
<!DOCTYPE html>

<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html"/>
    <title>Height Checker</title>
</head>

<body>
    <center>
        <script src="Supermantest.js"></script>
        <h1>Height Checker</h1>
        <p>Input your height below</p>

        <p>
          <label>Height</label>
          <input id="inputHeight" type="number" placeholder="Height" >
        </p>
        <p>

        <button onclick="input()">Submit</button>
        <p><span id="tooTall"></span></p>
        <p><span id="tooShort"></span></p>
    </center>
    
    <script>
        var height, tall, sort;
        
        function input(){
            tall = 200;
            sort = 130;
            height = document.getElementById('inputHeight').value;
            
             if(height > tall) {
                document.getElementById('tooTall').innerHTML = 'You are too tall bozo';
            } else if(height < sort) {
                document.getElementById('tooShort').innerHTML = 'You are too short bozo';
            }
        }
    </script>
</body>

</html>
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom