javascript - Variable Returning NaN Value - Cannot find out why -
i having pickup in business left off many years ago aging texting system.
it built using asp classic , sends string api texts out, neither here nor there. problem have no js experience, am sql developer , did little bit of asp classic (vbscript) years ago.
this piece of jscript picks information several form boxes , places them in string passed variable on processing page text out. fields 'qvalue, indemnity , excess' numeric. cover text , replacing cover text 'nan' understand 'not number' is, not number want text string.
here snippet of code in question:
<script type="text/javascript"> function changemessagetext() { var messagetxt = document.getelementbyid('message').value var qvalue = document.getelementbyid('qvalue').value var cover = document.getelementbyid('cover').value var excess = document.getelementbyid('excess').value var indem = document.getelementbyid('indemnity').value var messagetxt=messagetxt.replace("[qvalue]", + qvalue) var messagetxt=messagetxt.replace("[cover]", + cover2) var messagetxt=messagetxt.replace("[excess]", + excess) var messagetxt=messagetxt.replace("[indem]", + indem) document.getelementbyid('messagetext').innerhtml = messagetxt; } </script>
cheers.
when string.replace(searchvalue,newvalue)
, there no need of +
before newvalue
var messagetxt=messagetxt.replace("[qvalue]", qvalue) //cover or cover2 whichever appropriate var messagetxt=messagetxt.replace("[cover]", cover) var messagetxt=messagetxt.replace("[excess]", excess) var messagetxt=messagetxt.replace("[indem]", indem)