Frage

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.

War es hilfreich?

Lösung

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

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top