javascript - Printing to text area -


how preset values in table using javascript?

<u><h1>rabbits vs foxes population model</h1></u>     <form name = "rabbits">     <table border = "3">     <tr><td>no. of rabbits</td><td><center><input type="number" id="no_rabbits" /></center></td></tr>     <tr><td>death rates</td><td><center><input type="number" id="death" /></center></td></tr>     <tr><td>birth rates</td><td><center><input type="number" id="birth" /></center></td></tr>     <tr><td>no. of foxes</td><td><center><input type="number" id="foxes" /></center></td></tr>     <tr><td>rabbit conditions</td><td> normal <input type="radio" name="condition" value="normal"> cold <input type="radio" name="condition" value="cold"> fires <input type="radio" name="condition" value="fires">excellent <input type="radio" name="condition" value="excellent"></td></tr>     <tr><td> graph rabbits</td><td><input type="checkbox" name="graph" value="answer"></td></tr>     <tr><td><button type = "button" onclick="addyear()"> 1 year passes </button></td><td>  </td></tr>     </table>     </form> 

you can either set value when declaring inputs (eg: <input type="number" id="no_rabbits" value="23"/>) or javascript , target inputs using id of each , set value. note altered h1 structure - better apply css rule h1 have <u> outside of h1. not sure value each - set 1 - 4 demonsstrate. addyear function not declared , therefore throwing error on click. removed <center> tags - no longer supported , should use css apply centering css rules desired td's.

another thing - though these inputs set type = "number" still return string - need parse them (using parseint or parsefloat) number calculations.

document.getelementbyid('no_rabbits').value="1";  document.getelementbyid('death').value="2";  document.getelementbyid('birth').value="3";  document.getelementbyid('foxes').value="4";
h1{text-decoration: underline}
<h1>rabbits vs foxes population model</h1>      <form name = "rabbits">      <table border = "3">      <tr><td>no. of rabbits</td><td><input type="number" id="no_rabbits" /></td></tr>      <tr><td>death rates</td><td><input type="number" id="death" /></td></tr>      <tr><td>birth rates</td><td><input type="number" id="birth" /></td></tr>      <tr><td>no. of foxes</td><td><input type="number" id="foxes" /></td></tr>      <tr><td>rabbit conditions</td><td> normal <input type="radio" name="condition" value="normal"> cold <input type="radio" name="condition" value="cold"> fires <input type="radio" name="condition" value="fires">excellent <input type="radio" name="condition" value="excellent"></td></tr>      <tr><td> graph rabbits</td><td><input type="checkbox" name="graph" value="answer"></td></tr>      <tr><td><button type = "button" onclick="addyear()"> 1 year passes </button></td><td>  </td></tr>      </table>      </form>


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -