html - Javascript function not returning a value -


i have javascript function check value text box , if text box not blank outputs statement. text box take numeric value, want include numeric value output html.

here html

   <br><label id="cancelphonelabel">1-800-555-1111</label>    <br><label id="mdamountlabel">monthly donation: <td>     <input type="text" id="mdamountbox" style="width:50px;" name="md_amt" value="" placeholder="monthly" onkeyup="monthlycheck()" autocomplete="off">     <br><label id="mnthlychkdiscolabel">&nbsp;</label> 

and javascript

 function monthlycheck() {  var mnthchk = document.getelementbyid("mdamountbox").innerhtml; <---i want pass value of box var cancelphone = document.getelementbyid("cancelphonelabel").innerhtml;    if (mnthchk.value != "") {      var newhtml = "<span style='color:#24d330'> monthly pledge in amount of $<label id='dollarlabel'>&nbsp;</label> valid , deducted time every month<br> untill notify of cancellation calling <label id='cancelphonelistlabel'>&nbsp;</label> </span>";      document.getelementbyid("mnthlychkdiscolabel").innerhtml = newhtml;     document.getelementbyid("cancelphonelistlabel").innerhtml = cancelphone;     document.getelementbyid("dollarlabel").innerhtml = mnthchk;   <----passed here 

i cant value passed, shows blank, can hardcode value , output fine, how jsfiddle http://jsfiddle.net/rn5hh/4/

thanks in advance

input elements don't have child nodes, therefore innerhtml blank. if want read value, use value property.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -