我想将PHP变量发送到modal,但还需要获取一个PHP变量
我有两种以上的表格,比如我想将PHP变量发送到modal,但还需要获取一个PHP变量,php,ajax,variables,Php,Ajax,Variables,我有两种以上的表格,比如 <body> <form id="form1"> <input type="hidden" name="var1" value="value1"> <input type="submit" name="button1" data-toggle='modal' data-target='#myModal'> </form> <form id="form2"> <input
<body>
<form id="form1">
<input type="hidden" name="var1" value="value1">
<input type="submit" name="button1" data-toggle='modal' data-target='#myModal'>
</form>
<form id="form2">
<input type="hidden" name="var2" value="value2">
<input type="submit" name="button2" data-toggle='modal' data-target='#myModal'>
</form>
<form id="form3">
<input type="hidden" name="var3" value="value3">
<input type="submit" name="button3" data-toggle='modal' data-target='#myModal'>
</form>
</body>
我试着向同一模态发送1个值,并尝试使用变量
我需要知道哪个按钮发送哪个变量
<div class="modal fade" id="userEdit">
<div class="modal-dialog modal-lg" 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>
</div>
<div class="modal-body">
<?php
// I need to know which button send which variable
$var = $_POST["var1"];
echo ($var);
?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" name="button1">Submit</button>
</form>
</div>
</div>
</div>
</div>
&时代;
接近
提交
我怎样才能做到。或者你有什么建议我怎么做?
我用Ajax尝试了很多次,但都没有成功。你能给我举个有效的例子吗?
谢谢在您的模式中尝试以下内容:
for($i=1;$i<=10;$i++) {
$var = '';
if(isset($_POST["var".$i])) {
echo 'Horray, its var number '.$i;
$var = $_POST["var".$i];
break;
}
echo ($var);
}
for($i=1;$ibrowser具有开发人员模式,您可以使用这些模式在代码运行时检查代码。