Benedict John Payot
Benedict John Payot

Reputation: 33

Multiplying a textbox input value on the same textbox

I can't figure out how to do this right. I've achieved computing values using 3 textboxes. But what I want is when I input a value, it would automatically multiply on the value that I've assigned without the use of another textbox. Is this achievable in javascript?

Upvotes: 1

Views: 56

Answers (1)

user2040578
user2040578

Reputation: 51

Yes its achievable, you can use jQuery for this , here is example : http://jsfiddle.net/26vmdtcj/

add the input with this code:

<input id="input_id" type="text">

add javascript :

$('#input_id').on('change', function() {
    $(this).val($(this).val() * 3);
});

and you are ready, also dont forget to add jquery with this :

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>

Upvotes: 1

Related Questions