javascript - HTML form field update on another field change -


i have form updates total based on field values entered on form when user leaves each field. works fine want update 1 of entry fields percentage of another.

i have in js

var theform = document.forms[frm]; var etotal = theform.elements["total"]; var epremium = theform.elements["premium"]; if (etotal.value > 0) {     var premamount = parsefloat(etotal.value * epremium.value / 100); } var divobj = document.getelementbyid('premamount'); divobj.innerhtml = premamount.tofixed(2); 

which called with

onblur="addprem('totals')" 

the original value in totals field mysql table 770.00 php script produces following html

<input name="premamount" tabindex="1" class="ent" id="premamount" size="2" value="77.00"> 

when change total 888.00 following

<input name="premamount" tabindex="1" class="ent" id="premamount" size="2" value="77.00">88.80</input> 

so looks it's working writing div rather field itself

can me please

don't set innerhtml, set value

var theform = document.forms[frm]; var etotal = theform.elements["total"]; var epremium = theform.elements["premium"]; if (etotal.value > 0) {     var premamount = parsefloat(etotal.value * epremium.value / 100); } var divobj = document.getelementbyid('premamount'); divobj.value = premamount.tofixed(2); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -