[英]Bootstrap Modal Dialog on submitted not displaying id value
I've a problem using a modal dialog of bootstrap.我在使用引导程序的模态对话框时遇到问题。 This is my code: I'd like displaying id button correctly not just open the modal dialog but it not works.
这是我的代码:我想正确显示 id 按钮,而不仅仅是打开模态对话框,但它不起作用。 It displaying always blank.
它总是显示空白。 But if I change type ' button ' with ' submit ' get correctly id but not displaying the modal dialog.
但是,如果我将类型“按钮”更改为“提交”,则会获得正确的 id 但不显示模态对话框。 What's the problem??
有什么问题?? Thank's for the attention.
谢谢关注。 This is my code:
这是我的代码:
<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>
This behavior is what you coded, let's me explain what is happening.这种行为就是你编码的,让我解释一下发生了什么。
Why is this not working ?为什么这不起作用?
You put your modal button in a form but you don't use a form in your modal.您将模态按钮放在表单中,但没有在模态中使用表单。 So if you change your modal button to a submit, it will submit it when you click it but your modal is not opening and even... the page is already submitting a form.
因此,如果您将模态按钮更改为提交,它会在您单击它时提交它,但您的模态没有打开,甚至……页面已经在提交表单。
Your modal does not contain any <form>
, so your Save button is not in a <form>
and will never submit anything.您的模态不包含任何
<form>
,因此您的保存按钮不在<form>
并且永远不会提交任何内容。
How to fix that ?如何解决?
First remove the form tag wrapping your modal button, it's useless.首先删除包裹你的模态按钮的表单标签,它没用。 Put a form tag directly as child of .modal-content and put the input data you need in it.
将表单标签直接作为 .modal-content 的子标签,并将您需要的输入数据放入其中。
How could I help you more ?我怎么能帮到你更多?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.