我可以问一下,如果没有带有ajax的php中的提交按钮,是否可以打印“已选中”单选按钮的结果?
在下面的代码中,我想在点击“是”单选按钮时打印“谢谢”;并且“你确定吗?”单击“否”按钮而不刷新页面时。
<script>
function getEmail(int){
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("emailQ").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", "index.php?q="+int, true);
xmlhttp.send();
}
</script>
<div id = "emailQ">
<li class="nav-header">Please confirm your facebook email:</li>
<li><?php echo $_SESSION['EMAIL']; ?></li>
<form action="" method="post">
<input type="radio" name="email" onclick="javascript: submit.getEmail()" value="Thank You"> Yes
<input type="radio" name="email" onclick="javascript: submit.getEmail()" value="Are you sure?"> No
</form>
<?php
if(isset($_POST['email'])){
echo " ".$_POST['email'];
}
?>
</div>