views:

54

answers:

1

How do I Create a webpage using JavaScript that takes a number from the user and compares it against three ranges of numbers, unsing 3 functions, checklow(), checkmedium() and checkhigh()?

+1  A: 

html:

<form onsubmit="myValidation()">
    <input type="text" id="t1" name="t1" />
    <input type="text" id="t2" name="t2" />
    <input type="text" id="t3" name="t3" />
    <input type="submit" />
</form>

javascript:

    function myValidation()
    {
        for (var i=0; i < 3 ; i ++)
        {
            var t = document.getElementById('t'+(i+1)).value;
            if checklow(t)
                alert('low');
            if checkmedium(t)
                alert('medium');
            if checkhigh(t)
                alert('high');
        }
    }

now you have to write your 3 functions...

Ghommey