我正在使用javascript和PHP生成表单,但无线电输入不起作用。我点击了单选按钮,它没有检查。我的代码出了什么问题?
function showMenu()
{
...
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("game").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","GetGameMenu.php",true);
xmlhttp.send();
}
这是来自GetGameMenu.php的回声:
<?php
echo '<form id="menuGame" action="GetGame.php" method="post" onSubmit="showGame(); return false;">
<div id = "bigDiv">
<div class="divs">
<label>SELECT DIFICULTY</label>
<div>
<input type="radio" id="easy" name="dificulty"/>
<label for="easy">Easy</label>
</div>
...
</div>
<input type="submit" class="buton" id="butPlay" value="PLAY">
</form>';
?>
我发现问题是css风格。我有位置:亲戚,现在我把位置:绝对而且有效。
答案 0 :(得分:1)
从表单的onsubmit事件中删除return false。它应该如下。
<form id="menuGame" action="GetGame.php" method="post" onSubmit="showGame();">
还要确保方法showGame()
不返回false。然后表格将成功提交。