javascript - A button to show the chosen option -
according code choose game games table, trying have button called show
show chosen game. like:
<input type ="submit" value= "show" name="show">
i tried
`<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("#hide").click(function(){ $("p").hide(); }); $("#show").click(function(){ $("p").show(); }); }); </script>`
but somehow missing or did not work. here code:
<div id="content"> <article> <h2> games</h2> <form action='games.php' method='post'> <p>show</p> <select size= "1" name='gameid' > <option value ="show"> choose game </option> here code <?php include('dbaccess.php'); $mysqli = new mysqli($dbhost,$dbusername,$dbpassword,$dbname); $mysqli->set_charset('utf8'); if ($mysqli->connect_error) {print("<p>fail: ".$mysqli->connect_error."</p>");} $result = $mysqli->query("select * game;"); if ($mysqli->error) {print("<p>fail: ".$mysqli->error."</p>");} if ($result->num_rows == 0) { print("<p>ingen data.</p>"); } else { while($row = $result->fetch_array()) { print "<option value=$row[0]>$row[1]:$row[2]:$row[3]:</option>"; } } $mysqli->close(); ?> </form>
your function expects tag id of show
:
$("#show").click(function(){ $("p").show(); });
so need add id button:
<input type ="submit" value= "show" name="show" id="show">
likewise hide
id.
Comments
Post a Comment