I have button using an HTML a
tag. I have a button which has a value of 10
. If I click on this button 2 times, the value is appended into the first textbox as 2
and second textbox as 20
(value of button (10) * no of button click (2))
Same as if I click 3 times, the value is appended into first textbox as 3
and the second textbox as 30
(value of button (10) * no of button clicks (3))
10 * 2 = 20
10 * 3 = 30
Above scenario is for append value into textbox at runtime onclick of button.
Have a look on this: https://jsfiddle.net/0r0ewwhq/10/
<body>
<button id="addButton" value="10">Add</button>
<button id="delButton" value="10">Remove</button>
<br>
<input type="text" value="0" id="count" name="count"/>
<input type="text" value="0" id="value" name="value"/>
</body>
$("#addButton").on( "click", function(e) {
$("#count").val( parseInt( $("#count").val() ) + 1 );
$("#value").val( parseInt( $("#count").val() ) * parseInt( $(this).val()) );
});
$("#delButton").on( "click", function(e) {
if (parseInt($("#count").val()) > 0)
{
$("#count").val( parseInt( $("#count").val() ) - 1 );
}
else
{
$("#count").val(0);
}
$("#value").val( parseInt( $("#count").val() ) * parseInt( $(this).val()) );
});