<html>
<script>
function remain()
{
var k=0;
var rem=<?php echo $count; ?>;
var cap=document.getElementById("cap").value;
var k=k+cap;
var diff=rem-cap;
document.getElementById("demo").innerHTML = diff;
}
</script>
</html>
<html>
<form method="post" action="list.php" target="_blank">
Enter the capacity:
<input type="number" name="cap" id="cap" min=1 max=36 onchange="remain()">
<input type="submit" id="submit" value="get seating">
</form>
</html>
My question is: in the HTML form I will enter the capacity. When I entered the capacity it will be directed to javascript and remaining strength must be show by subtracting the capacity from the total count (ex: i entered the capacity as 36 and let the count be 100).
Now the cap 36 is less from 100 and remaining 64 will be shown. But when again I entered the cap 36 it should be less from remaining 64. But this was not happening.