如何将模式中的选项值从PHP和HTML中拉到表单中?

时间:2016-07-13 17:07:15

标签: javascript php jquery html twitter-bootstrap

如何将data-mylink中的数据从bootstrap中提取到模式中?或者我必须像我一样使用PHP字符串吗?我知道如何使用JQuery(您可能会注意到代码),但想知道如何使用PHP和HTML执行此操作。我在特定环境中限制使用javascript,所以我需要以这种方式学习它。

PHP和HTML:

$rowaudit1=$row[auditID];
<button type='button' id='print_audit' 
 data-mylink=\"<?php $rowaudit1 ?>\"
                    class='btn btn-default btn-xs' data-toggle='modal' data-target='#print_audit_form' value='Print'>Print</button>

我使用php将$ rowaudit1拉入模态,然后Modal部分让我对如何将选项值拉入表单感到困惑:

<div class="modal" id="print_audit_form" style="z-index:10000" role="dialog" aria-labelledby="basicModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h4 class="modal-title">
            Printing Options</h4>
            </div>
            <div class="modal-body">
                <h3>
                    <table class="table table-bordered">
                    <tbody>
                        <tr>
                    <td>
                        Filename: <input type="text" class="form-control" id="print_name" 
                        name="print_name" /><br/><br/>
                        Orientation: <select name="print_orient" id="print_orient">
                                        <option value="portrait">Portrait</option>
                                        <option value="landscape">Landscape</option>
                                    </select><BR/><BR/>
                        View Options: <select name="download_option" id="download_option">
                                        <option value="0">Display</option>
                                        <option value="1">Download</option>
                                    </select>
                    </td>
                    <td>Enter the filename for Downloading(optional), orientation, and if you want to view or download the audit.</td>
                </tr>
                </tbody>
                </table>

                </h3>
            </div>
            <div class="modal-footer">
                <form role="form" action='print_audit.php?auditID="<?php $rowaudit1 ?>"&action=print&print_name="+print_name+"&print_orient="+print_orient+"&download_option="+download_option+"&type="+value' method="get" >
                    <div class="form-group">

当我点击此表单按钮时,有一种方法可以将该值放入操作中 - &amp; type =“+ value?

                        <input type="button" class="btn btn-default" id="print_audit_form_button" value="PDF"/>
                        <input type="button" class="btn btn-default" id="print_audit_form_button_web" value="Web"/>
                        <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
                    </div>
                </form> 
            </div>
        </div>
    </div>
</div>

这是我的Jquery我试图让它学习PHP HTML路线:

$('#print_audit_form').on('shown.bs.modal', function (e) {
        var btn = $(e.relatedTarget);
        var auditID = btn.data('mylink');
    $("#print_audit_form_button").click(function(){

                 var print_name = $("#print_name").val();

                 var print_orient=$("#print_orient").val();
                 var download_option=$("#download_option").val();
                //alert(auditID+print_name+print_orient+download_option);

                window.open("print_audit.php?auditID="+auditID+"&action=print&print_name="+print_name+"&print_orient="+print_orient+"&download_option="+download_option+"&type=pdf");

                 //window.location.reload(true);
                return false; 
            });
         });

0 个答案:

没有答案