javascript - How to get selected radio button value onclick from php -
i want selected radio button's value in php.
code: update.php
<html> <head> <link rel="stylesheet" href="css/common.css" type="text/css"> <link rel="stylesheet" type="text/css" href="css/page.css"> <link href="css/loginmodule.css" rel="stylesheet" type="text/css" /> <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> </head> <body> <h1>welcome <?php echo $_session['sess_first_name']; ?></h1> <a href="member-profile.php" class="log">my profile</a> | <a href="logout.php" class="log">logout</a> <p>this password protected area accessible admins. </p> <center> <div class="pan"><br><br> <div class="head">remove theater list</div> <form action="<?php echo $_server['php_self']; ?>" method="post" > <table> <tr> <td> <table> <tr> <td><label for="theatername">theater name</label></td> <td> <?php try { $dbh = new pdo('mysql:dbname=theaterdb;host=localhost', 'tiger', 'tiger'); } catch (pdoexception $e) { echo 'connection failed: ' . $e->getmessage(); } $sql = "select theater_name theater;"; $sth = $dbh->prepare($sql); $sth->execute(); echo "<select name='theater_name' id='course' onchange='showuser(this.value);'>"; echo "<option>----select theater----</option>"; while ($row = $sth->fetch(pdo::fetch_assoc)) { echo "<option value='" . $row['theater_name'] . "'>" . $row['theater_name'] . "</option>"; } echo "</select>"; ?> </td> </tr> </table> </td> </tr> </form> <tr> <td> <form method="post"> <table> <tr> <td><label for="address">address</label></td> <td><div id="txthint"> </div></td> </tr> <tr> <td></td> <td><input type="submit" name='remove list' value="remove list" class="getvalue" onclick="< ? php myfunc() ? >"/></td> </tr> </table> </table> </form> <br><br> </tr> </td> <?php if (isset($_post['submit'])) { echo $_post['address']; } ?> </div> </center> </body> </html>
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 theater lower(theater_name) = :q'; $sth = $dbh->prepare($sql); $sth->bindvalue(':q', $q); $sth->execute(); echo "<form name='theater' method='post' action='update.php'>"; 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; ?>
the html radio button in gettheater.php
page. running update.php
gettheater page opening in update.php
how can selected radio button value , want selected radio button value in update.php
.
how can this?
check if form has been submitted, if has use $_post[]
access data.
see http://php.net/manual/en/reserved.variables.post.php
you may want include submit button, allow check if form has been submitted in first place.
echo "<form name='theater' method='post' action='update.php'>"; echo '<input type="submit" value="enter" name="submit">';
to check
if (isset($_post['submit'])) { //do }
this work, if doesn't try using hidden field.
Comments
Post a Comment