How to auto calculate prince using javascript?

Auto Calculate Price

File name : index.php

<!DOCTYPE html>
<html>
<body>
<h1>How to Auto Calculate Price in Javascript</h1>
<form name="frm-pin" method="post" action="pin-index-a.php">
<input type="hidden" name="mode" value="PinRequest" />
<label class="ittutorial-text-green"><b>Number Of Pin</b></label>
<select name="tot_pin_requested" onchange="calculateAmount(this.value)" required>
<option value="" disabled selected>Choose your option</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<label><b>Total Amount</b></label>
<input class="ittutorial-input ittutorial-border" name="tot_amount" id="tot_amount" type="text" readonly>
<script>
function calculateAmount(val)
{ var tot_price = val * 100;
//display the result
var divobj = document.getElementById('tot_amount');
divobj.value = tot_price;
}
</script>
<body>
</html>

Output :-



Output :-

Auto Calculate Price in Javascript




Auto Calculate GST in Javascript by select price

File name : index.php

<!DOCTYPE html>
<html>
<body>
<form name="frm-pin" method="post" action="pin-index-a.php">
<input type="hidden" name="mode" value="PinRequest" />
<label class="ittutorial-text-green"><b>Choose price</b></label>
<select name="tot_pin_requested" onchange="calculateAmount(this.value)" required>
<option value="" disabled selected>Choose your option</option>
<option value="1000">1000</option>
<option value="2000">2000</option>
<option value="3000">3000</option>
<option value="4000">4000</option>
<option value="5000">5000</option>
</select>
<label><b>Total Amount after tax</b></label>
<input class="ittutorial-input ittutorial-border" name="tot_amount" id="tot_amount" type="text" readonly>
<script>
function calculateAmount(val)
{
var price = val * 1;
//display the result
var tot_price=price+(price*0.18);
var divobj = document.getElementById('tot_amount');
divobj.value = tot_price;
}
</script>
<body>
</html>

Calculate GST by input value in text box Jquery

File name : index.php

<!DOCTYPE html>
<html>
<body>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
</head>
<h1>GST Calculation</h1>
<form method="post" action="">
<input type="hidden" name="mode" value="PinRequest" />
<label><b>Fee</b></label>
<input class="ittutorial-input ittutorial-border" name="pages" id="pages" type="text"><br><br>
<label><b>Total Amount</b></label>
<input class="ittutorial-input ittutorial-border" name="tot_amount" id="tot_amount" type="text">
<input type="submit" name="save" value="submit">
</form>
<script>
$(document).ready(function() {
$('#pages').keyup(function(ev){
var total = $('#pages').val() * 1;
var tot_price = total+(total*0.18);
var divobj = document.getElementById('tot_amount');
divobj.value = tot_price;
});
});
</script>
<body>
</html>

Output :-

GST Calculation








Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here