get - GetElementById Javascript can't access a value -


<html> <head> <title>calculator</title>  <style type = "text/css"> #calculator{ width:164px; top:20%; right:50%; position:absolute; border:1px black solid; background-image:url('images.jpg'); }  #matrix { float:right; border:1px black solid; width:100px; } #row1{ position:relative; width:17px; } </style>  </head> <body>  </div> <div id = "matrix"> <form> <table>     <tr><td style = "width:40px"><input type = "text" id = "one"></input></td>     <input type = "number" id = "two"></input></td></tr>      <tr><td><input type = "number" id = "three"></input></td>     <input type = "number" id = "four"></input></td></tr>  </table> <input type = "submit" value = "count" onclick = "calculate();"></input> </form> </div> <script language = "javascript" type = "text/javascript"> function calculate(){ var = document.getelementbyid('one').value;  alert(a); }  </script>  </body> </html> 

in function have can't acess element id properly, when try alert varible, alert box empty.i had javascript code in head earlier,but didn't work neither.moving body section didn't change situation.would greatful if me fix error in javascript, please not write jquery code alternative.thanx.

add id input , change button:

<input id="count" type="button" value="count"> 

and use this:

var count = document.getelementbyid("count").addeventlistener("click", calculate, false); function calculate() {     var = document.getelementbyid('one').value;     alert(a); } 

see on jsfiddle
note: cleaned markup little


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -