mercredi 29 mars 2017

How to write javascript code to create an application that averages Low and High daily temperatures as input by the user

 [enter image description here][1] 

I am asked to write javascript code to calculate the average low and high temperatures.

  • List item

An if statement must be used to ensure that the user enters both low and high temperatures for any given day before the form is submitted. If the user does not enter one or both of the temperatures, a message or messages must be displayed to tell the user that valid low and high temperatures must be entered.

The low and high temperature values entered from the html form must be processed into an array or arrays with loops.
Any help would be appreciated. following the html code I got. I am also attached a picture that shows the final result.

<form action="#" method="post" id="temp">

    <fieldset>

    <legend>Average Low and High Temperatures</legend>
 <div>
     <label for="lowTemp"> Low Temperature </label>
     <input type="number" name="lowTemp" id="lowTemp" required>
</div>
<div>
     <label for="highTemp"> High Temperature </label>

     <input type="number" name="highTemp" id="highTemp" required>

  <div><input type="submit" value="Add temperatures!" id="submit"></div>

    </fieldset>
 </form>       

Aucun commentaire:

Enregistrer un commentaire