Monday, 19 August 2013

How to get the radio button value from php

How to get the radio button value from php

i want to get the radio button value in php.The thing is i am having the
drop down in one page, when i select some value from dropdown, it sends
the value to ajax and php and from php page it is generating the radio
button.
Now i want to get the radio button value. How can i get it?
code
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>
Code: 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;
?>

No comments:

Post a Comment