使用javascript

时间:2019-03-27 19:01:44

标签: javascript php html bootstrap-modal

我正在尝试显示从下拉菜单中选择的数据以及引导程序模版上的按钮,这是一种确认提交的方式。当我按下按钮时,模态出现,但是表单中的值没有出现在模态上,我的代码如下:

HTML

<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="POST" id="apentry" name="apentry">

  <div class="btn-group" role="group">

<select class="form-control" id="weekstarting" name="weekstarting">
    <option value="one">Week starting: </option>
    <option value="one"><?php echo $week1 ?></option>
    <option value="two"><?php echo $week2 ?></option>
    <option value="three"><?php echo $week3 ?></option>
    <option value="four"><?php echo $week4 ?></option>
</select>
  </div>


  <div class="btn-group-vertical" role="group">
  <h3> Mon </h3>

  <input type="button" class="<?php echo $buttoncolour[0] ?>" name= "time_pickedm" value = "9:00" data-toggle="modal" data-target="#confirm-submit"/>

</div>

js

   $('#submitBtn').click(function() {
     /* when the button in the form, display the entered values in the modal */
     $('#timepicked').text($('#time_pickedm').val());
     $('#weekname').text($('#weekstarting').val());

});

$('#submit').click(function(){
     /* when the submit button in the modal is clicked, submit the form */
    alert('submitting');
    $('#apentry').submit();
});

模式

<div class="modal fade" id="confirm-submit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                Confirm Submit
            </div>
            <div class="modal-body">
                Are you sure you want to submit the following details?

                <!-- We display the details entered by the user here -->
                <table class="table">
                    <tr>
                        <th>Week</th>
                        <td id="weekname"></td>
                    </tr>
                    <tr>
                        <th>Time</th>
                        <td id="time_pickedm"></td>
                    </tr>
                </table>

            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                <a href="#" id="submit" class="btn btn-success success">Submit</a>
            </div>
        </div>
    </div>
</div>

任何帮助将不胜感激

0 个答案:

没有答案