I want to pass javascript variable to php file. Here I attached my code
function Calculate(val)
{
var h = document.getElementById('xyz').textContent ;
var result = h * val;
result = result.toFixed(2);
document.getElementById('lblRes').innerHTML ='$'+ result;
$('#ori_price').hide();
$.ajax ({
url: 'nonmembersdetail1.php',
type : 'POST',
data : {val : h},
success: function( result ) {
alert( result );
}
});
}
<?php
echo "<td ><label id='xyz' name='xyz'>". $row->nonmember_price ."</label></td>";
echo "<td ><input type='text' style='width:40px' id='words' name='qty' value='1' onchange='Calculate(this.value);' /></td>";
?>
In my nonmembersdetail1.php
code
echo ( $_POST['val'] );
I didn't get value in php file. Please anyone help me.Thanks in advance...