Increment Decrements certain fixed amount of text box value multiply based on select box value

This is some thing different concept The textbox value is fixed amount it may any amount but in this example i used the fixed amount is 108 rs. When you select the qty in select box based on the quantity the text box value should be increase by multiplying the select box value. For example if you select the select box qty is 3 means the text box value is 3*108 = 324rs. This concept will done by using the javascript and jquery.


I hope this example is very useful to you, Using this concept you can modify the things according to your project requirement. This is the simple concept using html, css, jquery, I provided the demo and download code link below you can use this. Click the demo link to check live  working example. Thanks. 






<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<style>
input{
    height: 35px;
}

</style>
</head>
<body>
<form action="" method="post" name="payuForm">
<label>ENTER YOUR QTY: </label>
<input id="qty" name="qty" value="1"  placeholder="ENTER YOUR QTY" autocomplete="off" type="number" min="1"><br/><br/>
<label>TOTAL AMOUNT: </label><input type="hidden"  id="price" name="price" value="108"  >
<input type="text"  id="amount" name="amount" value="108" readonly ><br/>
</form>
<script>
jQuery(document).ready(function($){
jQuery(document).bind("click", "#qty", function(e)
{
e.preventDefault();
var qty=$("#qty").val();
var price=$("#price").val();
var reqv=parseInt(qty);
var stockv=parseInt(price);
if(reqv != 0)
{
var total=reqv*stockv;
$("#amount").val(total);
}
else
{
$("#amount").val("108");
}
});
});
</script>
</body>
</html>


Post a Comment

0 Comments