首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将表单值发送到Modal

将表单值发送到Modal
EN

Stack Overflow用户
提问于 2021-04-22 01:51:55
回答 1查看 58关注 0票数 0

我有一个表单,要求3个字段。表单提交后,应该会打开一个模式。在模式中,应显示预算摘要。预算汇总数据从数据库中提取,值基于输入的3个表单域。我似乎不能让值显示在模式中,这样查询就可以工作了,但是模式确实打开了。

以下是模式代码:

代码语言:javascript
复制
    <!-- Large modal -->
<div class="modal fade bd-example-modal-lg" tabindex="-1" id="myLargeModalLabel" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content p-4">
     <h4 class="modal-title">Budget Summary</h4>For Account: <?php echo $account; ?>, Fund: <?php echo $_POST['fund2']; ?>, DeptID#: <?php echo $deptID; ?><br><em>The budgeted balance is an estimate.</em></h4>
      <br>  <?php if ($budget_summary->TotalRows == 0) { // Show if mysqli recordset empty ?>There is no data. Please try your search again.<?php } ?>
        <?php if ($budget_summary->TotalRows > 0) { // Show if mysqli recordset empty ?><table width="100%" class="table table-responsive" border="0" cellspacing="2" cellpadding="6" class="display" id="example2">
            <thead>
              <tr>
                <th align="left" valign="top">Budgeted Amount</th>
                 <th align="left" valign="top">Budgeted Balance</th>
                 <th align="left" valign="top">Program</th>
                </tr>
            </thead>
            <tbody>
              <?php
while(!$budget_summary->atEnd()) {
?><tr>
<td valign="top">$<?php echo($budget_summary->getColumnVal("budgeted_amount")); ?></td>
<td valign="top">$<?php echo($budget_summary->getColumnVal("budgeted_balance")); ?></td>
<td valign="top"><?php echo($budget_summary->getColumnVal("program")); ?></td>
                  </tr>
                <?php
  $budget_summary->moveNext();
}
$budget_summary->moveFirst(); //return RS to first record
?>
            </tbody>
          </table><?php } ?>
          <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

下面是sql查询:

代码语言:javascript
复制
<?php
$budget_summary = new WA_MySQLi_RS("budget_summary",$sa,0);
$budget_summary->setQuery("SELECT * from budget_summary where fund = ? and account = ? and deptID = ?");
$budget_summary->bindParam("i", "".$_POST['fund '] ."", "-1"); //colname
$budget_summary->bindParam("i", "".$_POST['account']  ."", "-1"); //colname2
$budget_summary->bindParam("i", "".$_POST['funding_department'] ."", "-1"); //colname3
$budget_summary->execute();
?>

表单如下所示:

代码语言:javascript
复制
<form method="POST" id="frm" name="frm">
<div class="row">
    <div class="col mb-2">
    <label for="account">Account:</label>
   <select class="form-control" name="account2" id="account2" required>
      <option></option>
     <?php
while(!$accounts->atEnd()) { //dyn select
?>
                <option value="<?php echo($accounts->getColumnVal("account")); ?>"><?php echo($accounts->getColumnVal("account")); ?>: <?php echo($accounts->getColumnVal("description")); ?></option>
                <?php
  $accounts->moveNext();
} //dyn select
$accounts->moveFirst();
?>
      </select>
    </div>
    <div class="col mb-2">
    <label for="fund">Fund:</label>
     <select class="form-control" name="fund2" id="fund2" required>
      <option></option>
     <?php
while(!$funds->atEnd()) { //dyn select
?>
                <option value="<?php echo($funds->getColumnVal("fundID")); ?>"><?php echo($funds->getColumnVal("fundID")); ?>: <?php echo($funds->getColumnVal("fund")); ?></option>
                <?php
  $funds->moveNext();
} //dyn select
$funds->moveFirst();
?>
      </select>
    </div>
  </div>
<div class="row">
    <div class="col mb-2"> 
            <label for="fund">Department ID#:</label>
             <input type="text" name="funding_department2" id="funding_department2" class="form-control input-md" autocomplete="off" value="" required>
    </div></div>
<button type="submit" name="submit2" id="submit2" class="btn-lg btn-info">Search</button>   
    </form>
    <script>
    $(document).ready(function() {
  $('#frm').on('submit', function(e){
      $('#myLargeModalLabel').modal('show');
      e.preventDefault();
  });
});
</script>

任何关于如何实现这一点的技巧都将不胜感激。我已经试了好几天才弄明白。谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-04-22 01:56:45

您是将数据直接插入到数据库中,还是插入到模式中的字段中?

尝试以下操作:

在字段中插入数据(如果有),然后尝试用PHP或Java打印它们,看看是否收到任何值。

如果你用java接收它们,并且可以用java打印它们:

您的客户端获得您插入的数据,但PHP是您的程序的服务器端。您需要使用php-语句获取数据。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67201089

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档