Jump to content

Update form input field


BinaryBridge
Go to solution Solved by maxxd,

Recommended Posts

I have a form that updates a total based on the fields values entered on a form when the user leaves each field.

This works fine but I also want to update one of the entry fields which is a percentage of another.

 

I have in my 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 is called with
onblur="addPrem('totals')"
 
The original value in the totals field from the MySQL table is 770.00
This produces the following html page
<input name="PremAmount" tabindex="1" class="ent" id="PremAmount" size="2" value="77.00">
 
When I change the total to 888.00 I get the following 
 
<input name="PremAmount" tabindex="1" class="ent" id="PremAmount" size="2" value="77.00">88.80</input>
 
So it looks like it's working but writing a div rather than into the field itself
 
Can anyone help me with this please
 
 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.