bid
bid

Reputation: 37

Multiplication with Ajax

I am working in a website where i am integrating order and payment gateway. I have three textbox. Textbox1, where i have the number of quantity and Textbox2, where i have cost of one order and in Textbox3 i am displaying the Total cost of Order. Now What i have to do is to get the Total order cost, depending upon number of order without page load with jquery or Ajax.

I have tried as follows, But it wont work.

$(document).ready(function() {

  $(".Textbox1").keyup(function(){

    var valone = $('#Textbox1').val();
    var valtwo = $('#Textbox2').val();
    var total = ((valone * 1) * (valtwo * 1));
    $('#Textbox3 ').text(total);
  });
});

Upvotes: 2

Views: 1146

Answers (2)

meson10
meson10

Reputation: 1954

use:

$('#Textbox3 ').val(total);

.val(value) Set the value of each element in the set of matched elements. You can read more on this here

Let me know if this helps.

Upvotes: 1

sausman
sausman

Reputation: 253

I'm not sure but is

$(".Textbox1").keyup

meant to be

$("#Textbox1").keyup

Is it not working at all, or are you having problems with the wrong total being calculated?

Upvotes: 0

Related Questions