In a page, I have a table with user entering field.
There are 4 fields, first three are user entering fields and the fourth field is auto calculating of the first three fields,if the user leaves a field the total field showing NaN. How to solve this problem?

Recommended Answers

All 4 Replies

NaN means not a number.

Solve this by showing us your code and we can then show you how to fix it.

Member Avatar

Once again Antony, you lead off without showing your code. It seems we have to pry it out of you. Please, pretty please with sprinkles on top: show your code - you're more likely to get help. Describing the form says nothing. Where's the js? Ah, it's up to us to guess? Sorry if that sounds a bit sarcastic, but we really need to sort this out.

function calcTotal(a,i,j)
    c = parseInt(a);
    h = document.getElementById('Hvalue'+i).value;
    document.getElementById('Hvalue'+i).value = c;
    d = parseInt(h)+parseInt(a);
    document.getElementById('Hvalue'+i).value = d;

    document.getElementById('total'+i).value =  d;

    document.getElementById('stuid'+j).readOnly = true; 
Member Avatar

Not sure what this is supposed to be doing.

Surely you just need to add the values?

Show your markup too. This is trying to get blood out of a stone Antony. Patience is a virtue but I'm running on empty.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.