Passing javascript to php varaiable

I want to pass total value to label as php varable

<button type="button" class="button" onClick="fnIntTotal()">Internal Total =</button>	 	 
			<script>				
			function fnIntTotal(){						
			var a = document.getElementById('txt_Lab').value;
			var b = document.getElementById('txt_Sample').value;
			var c = document.getElementById('txt_Wastage').value;	
			var total = parseInt(a || 0) + parseInt(b || 0) + parseInt(c || 0);
			document.getElementById('inttotal').innerHTML=total;
            document.getElementById('inttotal').value=total; 
				if (isNaN(a) || isNaN(b) || isNaN(c))
				{
					document.getElementById('inttotal').style.display="inline-block";
					document.getElementById("inttotal").style.color = "red"; 
					document.getElementById('inttotal').innerHTML="Enter a valid Number";					
				}
				else
				{
					document.getElementById("inttotal").style.color = "green";
				}								
				}									
			</script>				
			<label id='inttotal' name='inttotal' ></label>

set it in a form then POST, or AJAX.

not working through post,
send me ajax sample code

works perfect

https://www.php.net/manual/en/tutorial.forms.php

try it yourself, just google “PHP AJAX”.

Yeah not happening…

Sponsor our Newsletter | Privacy Policy | Terms of Service