I have a form with three inputs and a php file with a function conv()
with takes three paramater. I want when a user type in a textfeild( this text filed has onlick function called post())
the form data should be posted to php and results from php to be displayed in a filed with ID results. I have my code but its not working. Can any one help.
<script>
function post(){
var hr = new XMLhttpRequest();
var url = "curencyconvert.php";
var param = document.getElementsById("param").value;
var param2 = document.getElementsById("param2").value;
var param3 = document.getElementsById("param3").value;
var vals = "param="+param+"¶m2="+param2+"& param3"+param3;
hr.open("POST",url,true);
hr.sendRequestHeader("Content-type","application/x-www-form-urlencoded");
hr.onreadystatechange= function(){
if(hr.readyState==4 && hr.status==200){
var return_data = hr.responseText;
document.getElementById("results").innerHTML = return_data;
}
}
hr.send(vals);
}
</script>
And my PHP file is this:
function Conv($param,$param2,$param3){
$restults= $_POST['param'];
return $restults;
}