Question

I have 2 Ids #totalcbm and #gross, i want to divide both these values using jquery and to store the result in a new id #result.

How can i do this using jQuery.

Was it helpful?

Solution

var result = parseFloat(('#totalcbm').val()) / parseFloat(('#gross').val());
$('#result').val(result);

OTHER TIPS

This is damn simple if the divs contain a text.

var result = parseFloat($('#totalcbm').text()) / parseFloat($('#gross').text());
$('result').text(result);

If these are textboxes/textareas see this:

var result = parseFloat($('#totalcbm').val()) / parseFloat($('#gross').val());
$('result').val(result);

Please try to put your own efforts in such simple things.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top