-1
我想要使用php獲取所選單選按鈕的值。但是,當我嘗試回顯收音機的值時,它會返回'開',無論我提交表單時選擇哪個單選按鈕。在PHP返回的電臺選擇不是值
HTML:
<article>
<form id="quiz" method="post" action="question3.php">
<fieldset id="question">
<legend>Question 2</legend>
<p>Where was CoffeeScripts first stable build announced? <br />
<label for="github">GitHub</label>
<input type="radio" name="ans2" id="github" value="GitHub"/> <br />
<label for="hackernews">Hacker News</label>
<input type="radio" name="ans2" id="hackernews" value="Hacker News"/> <br />
<label for="coffeescript">CoffeeScript.com</label>
<input type="radio" name="ans2" id="coffeescript" value="CoffeeScript"/> <br />
<label for="dropbox">DropBox</label>
<input type="radio" name="ans2" id="dropbox" value="Dropbox"/> <br />
</fieldset>
<p><input type="submit" value="Submit Answer" id="subans" /></p>
</form>
</article>
然後進程頁上:
<?php
if (isset($_POST['ans2'])) {
$ans = $_POST['ans2'];
echo "<p>$ans</p>";
}
else {
echo "Nothing was selected.";
}
?>
就像我說的,這只是輸出 「關於」 頁面。
幫助感謝!
請分享您的代碼的形式部分。 –
您可能有另一個使用名稱「ans2」的元素來覆蓋值。 –
顯示'