html - Javascript not alerting input value -



html - Javascript not alerting input value -

the code below isn't working expected. have excluded rest of tags. whenever execute html, alert alerts nil @ all. has encountered problem before?

<p><input type="text" id = "earth"> come in weight on earth.<br><br></p> <script type="text/javascript"> function calculate() { var weight = input.earth.value; window.alert(weight); } </script>

you're not getting element correctly - input.earth means nothing. should utilize getelementbyid():

var weight = document.getelementbyid('earth').value;

javascript html web

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -