[英]Bootstrap Modal Dialog on submitted not displaying id value
我在使用引導程序的模態對話框時遇到問題。 這是我的代碼:我想正確顯示 id 按鈕,而不僅僅是打開模態對話框,但它不起作用。 它總是顯示空白。 但是,如果我將類型“按鈕”更改為“提交”,則會獲得正確的 id 但不顯示模態對話框。 有什么問題?? 謝謝關注。 這是我的代碼:
<table class="table table-bordered">
<tr>
<td> <input type="checkbox" id="box1" name="box1"> <b>Seleziona tutto</b></td>
<td> <b>Pratica</b> </td>
<td> <b>Filiale</b> </td>
</tr>
<?php
$query = mysql_query("SELECT * from plprat ") ;
while ($row = mysql_fetch_array($query)) {
echo "<tr>";
echo "<td><input type='checkbox' class='box' name='box[]' value=".$row['id']."></td>";
echo "<td>" . $row['pratica'] . "</td>";
echo "<td>" . $row['filiale'] . "</td>";
//echo "<td><form method='POST' action='Cancella.php'><button type='submit' name='Cancella' class='btn btn-default' value=".$row['id'].">Cancella</button></form></td>";
echo "<td><form method='GET'><button type='button' id='modifica' name='modifica' data-toggle='modal' data-target='#myModal' class='btn btn-default' value=".$row['id'].">Modifica</button></form></td>";
echo "</tr>";
}
?>
</table>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modifica dati</h4>
</div>
<div class="modal-body">
<?php
$id = $_GET['modifica'];
echo $id;
$query = mysql_query("SELECT * FROM plprat WHERE id = $id");
while ($row = mysql_fetch_array($query)) {
?>
<b>Pratica</b> <input type="text" id="pratica" name="pratica" value="<?php echo $row['pratica']; ?>">
<b>Filiale</b> <input type="text" id="filiale" name="filiale" value="<?php echo $row['filiale']; ?>">
<?php
}
?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Chiudi</button>
<button type="submit" id="salva" name="salva" class="btn btn-primary">Modifica</button>
</div>
</div>
</div>
</div>
這種行為就是你編碼的,讓我解釋一下發生了什么。
為什么這不起作用?
您將模態按鈕放在表單中,但沒有在模態中使用表單。 因此,如果您將模態按鈕更改為提交,它會在您單擊它時提交它,但您的模態沒有打開,甚至……頁面已經在提交表單。
您的模態不包含任何<form>
,因此您的保存按鈕不在<form>
並且永遠不會提交任何內容。
如何解決?
首先刪除包裹你的模態按鈕的表單標簽,它沒用。 將表單標簽直接作為 .modal-content 的子標簽,並將您需要的輸入數據放入其中。
我怎么能幫到你更多?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.