0
獲得單選按鈕值我想要在php中獲得單選按鈕值。事情是我在一頁中下拉菜單,當我從下拉列表中選擇一些值時,它將值發送到ajax和PHP和PHP頁面它正在生成單選按鈕。如何從php
現在我想要獲得單選按鈕值。我怎麼才能得到它?
代碼
的index.php
<script>
function showUser(str) {
if(str=="") {
document.getElementById("txtHint").innerHTML="";
return;
}
if(window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","gettheater.php?q="+str,true);
xmlhttp.send();
}
</script>
<div id="txtHint">
</div>
代碼: gettheater.php
<?php
$q = strtolower(trim($_GET["q"]));
try {
$dbh = new PDO('mysql:dbname=theaterdb;host=localhost','tiger','tiger');
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$sql = 'SELECT address FROM theater WHERE LOWER(theater_name) = :q';
$sth = $dbh->prepare($sql);
$sth->bindValue(':q', $q);
$sth->execute();
echo "<form name='theater' method='POST'>";
echo "<table border='0' class='tabs'><tr><th>Theater Address</th><th>Select</th></tr>";
while($row = $sth->fetch(PDO::FETCH_ASSOC))
{
echo "<tr>";
echo "<td class='ad'>" . $row['address'] . "</td>";
echo "<td>";
echo '<input type="radio" name="address" value="43" />';
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo "</form>";
$dbh = null;
?>
你想訪問單選按鈕的值在哪裏?在您的JavaScript或您的PHP代碼? – Ygg
$ addressRadio = $ _POST ['address'];打印$ addressRadio; – rags
@Ygg我想要得到index.php中的單選按鈕的值 –