[英]A button to show the chosen option
According to my code you could choose a game from the games table, so I am trying to have a button which is called Show
to show the chosen Game. 根据我的代码,您可以从游戏桌中选择一个游戏,所以我想要一个名为Show
的按钮来显示所选择的游戏。 Something like: 就像是:
<input type ="submit" value= "Show" name="Show">
I tried this 我试过这个
`<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 something was missing or it did not work. 但不知何故,某些东西丢失了或者没有用。 Here is my 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 is my 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 * FROM 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 a tag with an id of show
: 您的函数需要一个id为show
的标记:
$("#show").click(function(){
$("p").show();
});
So you need to add the id to the button: 所以你需要将id添加到按钮:
<input type ="submit" value= "Show" name="Show" id="show">
Likewise with the hide
id. 与hide
ID一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.