I'm trying to pass 2 values from an HTML form into a javascript function, using a button and the Onclick="myfunction(value1,value2)". So far I'm having no luck.
You can view the website and the source code here: View Page
Here's my code:
Javascript - Ajax Call:
<script type="text/javascript">
function verification_email(name,email) {
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("result").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","send_verification_email.php?",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("name="+name+"++email="+email);
}
</script>
HTML Form:
<h3 class="subtitle">Verification Details:</h3>
<p><input type="text" class="form-control" placeholder="First Name" id="name" /></p>
<p><input type="text" class="form-control" placeholder="Email Address" id="email"/></p>
<p><button class="btn btn-primary" Onclick="verification_email('name','email')">Request Verifcation Code</button></p>
</form>
Is there a standard way to do this? Am I way off the mark?
Thanks for the help!