转账问题时如何获取信息
老师能不能用代码讲解一下,如何在点击转账的时候把用户ID传给模态框,以及如何获取到收款人和转账金额的值,页面都遍历过了!
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <form class="form-inline" action="select.php" method="post" enctype="multipart/form-data"> <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">转账</h4> </div> <div class="modal-body"> <p> 收款人: <select class="form-control"> <?php foreach ($rows as $row):?> <option value="<?php echo $row['id'];?>"><?php echo $row['name'] ?></option> <?php endforeach ?> </select> </p> <br /> <p>转账金额:<input type="text" class="form-control" id="exampleInputEmail1" name="trans_money" placeholder="请输入数字"></p> </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary" name="submit" id="submit" onclick="show(this)">确认转账</button> <button type="reset" class="btn btn-default">重置</button> </div> </div> </form> </div> </div>
万分感谢!
4
收起
正在回答
1回答
同学你好,通过js获取信息,代码如下:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <form class="form-inline" action="select.php" method="post" enctype="multipart/form-data"> <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">转账</h4> </div> <div class="modal-body"> <p> 收款人: <select name="id" id='transfer-person' class="form-control"> <?php foreach ($data as $row):?> <option value="<?php echo $row['id'];?>"><?php echo $row['name'] ?></option> <?php endforeach ?> </select> </p> <br /> <p>转账金额:<input type="text" class="form-control" id="exampleInputEmail1" name="trans_money" placeholder="请输入数字"></p> </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary" name="submit" id="submit" onclick="show(this)">确认转账</button> <button type="reset" class="btn btn-default">重置</button> </div> </div> </form> </div> </div> <script type="text/javascript"> $("#exampleModal").modal("hide"); $('#myModal').on('show.bs.modal', function (event) { // relatedTarget 事件属性返回与事件的目标节点相关的节点。 var a = $(event.relatedTarget) var userName = a.context.dataset.user; var modal = $(this); //获取select option value值 // console.log(userName); $("#transfer-person").each(function(){ $('#transfer-person').val(userName); }); }); </script>
祝学习愉快!
PHP常用技术与ThinkPHP5框架开发
- 参与学习 人
- 提交作业 225 份
- 解答问题 3372 个
掌握用PHP开发互联网网站的必备功能,掌握当下主流的Linux系统开发,并熟练使用热门框架ThinkPhp开发电商团购项目,是通向PHP工程师必经之路。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星