Jump to content

Javascript calculation only works in IE - not FF?! why?

Recommended Posts

I'm using this script to calculate the values of a number of fields, and then display the total on the next page. Since the values are numerical, the corresponding table fields are set to 'Number' and in this script I am also converting the variable to a number.

Does anybody have a clue why it only works in Internet Explorer, but not Firefox or Chrome? I'm really scratching my head...

Here's the code:

function calculate()
var v_q1a = document.getElementById('InsertRecordQ1a');
var q1a = parseInt( v_q1a.value);

var v_q1b = document.getElementById('InsertRecordQ1b');
var q1b = parseInt( v_q1b.value);

var v_q2a = document.getElementById('InsertRecordQ2a');
var q2a = parseInt( v_q2a.value);

var v_q2b = document.getElementById('InsertRecordQ2b');
var q2b = parseInt( v_q2b.value);

var v_q3 = document.getElementById('InsertRecordQ3');
var q3 = parseInt( v_q3.value);

var v_q4a = document.getElementById('InsertRecordQ4a');
var q4a = parseInt( v_q4a.value);

var v_q4b = document.getElementById('InsertRecordQ4b');
var q4b = parseInt( v_q4b.value);

var v_q4c = document.getElementById('InsertRecordQ4c');
var q4c = parseInt( v_q4c.value);

var v_q5 = document.getElementById('InsertRecordQ5');
var q5 = parseInt( v_q5.value);

var total = (q1a + q1b + q2a + q2b + q3 + q4a + q4b + q4c + q5);

document.getElementById('InsertRecordtotal').value = Math.round(total);
Link to comment
Share on other sites


Your script looks good to me. Is it still giving some problem?

It seems that you might be missing something else. Check your table, is there no data submitted for the field "total". If not then the script is not fine. If there is data for the field but its not showing up on datapage then there is some other error, may be the way you are passing and receiving the parameters.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...