Wayne Bunch Wayne Bunch - 1 year ago 39
Javascript Question

Jquery - Multiplying my two classes give no results

<div id="container">
<div class="jumbotron" id="group">
<form class="form-inline">
<div class="form-group">
<label for="groupNumber">Group:</label>
<input type="text" class="groupNumber" />
<div class="form-group inputTop">
<label for="quantity">Quantity:</label>
<input type="text" class="quantity" />
<div class="form-group inputTop">
<label for="systemPrice">System Price:</label>
<input type="text" class="systemPrice" />
<div class="form-group">
<label for="groupTotal">Group Total:</label>
<input type="text" class="groupTotal" />

<div class="row specs" id="pasted" contenteditable="true"></div>


$(document).ready(function() {
$('.inputTop input').keyup(multInputs);

function multInputs() {
$('.inputTop').each(function() {
var $quantity = $('.quantity', this).val();
var $systemPrice = $('.systemPrice', this).val();
var $groupTotal = ($quantity * 1) * ($systemPrice * 1)
$('.groupTotal', this).text($groupTotal);

JS Fiddle: https://jsfiddle.net/waynebunch/jh6uhL1p/5/

I've been staring at this for a while and am not seeing anything wrong. Basically, I'm trying to use JQuery to multiply
var $quantity
var $systemPrice
and have the result displayed in
var $groupTotal
. There will multiple "groups" of these. Can someone tell me what I'm doing wrong here, or if I'm way off? Thank you!

Answer Source


$('.groupTotal', this).text($groupTotal);


$('.groupTotal', this).val($groupTotal);