0
我在php中創建了動態按鈕。我需要在同一個主頁上打開新的表單,並在點擊按鈕時刷新頁面。如何解決這個問題如何在php中動態按鈕點擊事件打開新窗體
這裏是我的代碼,我已經嘗試
<?php
function dash() {
include 'config.php';
$sql = "SELECT roomno FROM roombook";
if($result = mysqli_query($db, $sql)){
$str = '';
while($row = mysqli_fetch_array($result)){
// generate array from comma delimited list
$rooms = explode(',', $row['roomno']);
//create the dynamic button and set the value
foreach ($rooms as $k=>$v){
$str .= '<input type="submit" class="Click" onClick="showDiv()" name="btn_'.$k.'" value="'.$v.'" id="btn_'.$k.'"/>';
}
//return $str;
}
return $str;
}else {
echo "ERROR: Could not able to execute $sql. " . mysqli_error($db);
}
mysqli_close($db);
}
?>
<!Doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>room boking</title>
<link href="css/bootstrap1.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/front.css">
</head>
<body>
<form mathod="post" action="">
<div class =" row box col-md-4" >
<div style="color:black"><?php echo dash();?></div>
</div>
<script>
function showDiv() {
document.getElementById('link').style.display = "block";
}
</script>
</form>
可能重複的[jquery驗證:防止表單提交](http://stackoverflow.com/qu estions/10305938/jquery-validation-prevent-form-submit) –
能否請你用deatail解釋 – Yogesh