I want to write using javascript the number entered in "tempo"... <html> head <title> Welcome to TempoToTime convertor! </title> <script language="javascript"> function calc() { var tempval = document['tempo'].value; document.write(tempval); } </script> </head> <body> Tempo value: <input type="text" name="tempo"><br> Notation: <input type="text" name="note"><br> <button type="button" onClick="javascript:calc();">Calculate!</button> </body> </html> Code (markup):
<html> <head> <title> Welcome to TempoToTime convertor! </title> <script language="javascript"> function calc() { var tempval = document.getElementById('tempo').value; document.getElementById('res').innerHTML = tempval; } </script> </head> <body> Tempo value: <input type="text" name="tempo" id="tempo"><br> Notation: <input type="text" name="note" id="note"><br> <input type="button" onClick="javascript:calc();" value="Calculate!"> <br /> <span id="res"></span> </body> </html> HTML:
Gee, sorry, forgot to point out what wasn't working! how stupid of me... anyway, the problem was that it didn't print the tempo.value ! (regardless of where printed and how)... even with the <div> etc. it doesn't work, when I tried to fix a value for tempval in the function it worked: var tempval = 12; Code (markup): something with getting the value is wrong...