在从下拉菜单中选择特定选项时,应弹出一个模态表单

时间:2015-10-10 20:32:44

标签: javascript jquery html

我一直试图从

弹出一个模态

enter image description here

每当用户从下拉菜单中选择选项c时 enter image description here

Code Snap :: 模态表格

<div id="loginmodal" style="display:none;">
    <h1>User Login</h1>
    <form id="loginform" name="loginform" method="post" action="index.html">
      <label for="username">Username:</label>
      <input type="text" name="username" id="username" class="txtfield" tabindex="1">

      <label for="password">Password:</label>
      <input type="password" name="password" id="password" class="txtfield" tabindex="2">

      <div class="center"><input type="submit" name="loginbtn" id="loginbtn" class="flatbtn-blu hidemodal" value="Log In" tabindex="3"></div>
    </form>
  </div>

下拉菜单::

<select class="selectpicker form-control" id="count">
     <option value="0" selected="selected">Select Variable</option>
     <option value="a">a </option>
     <option value="b">b </option>
     <option value="c">c </option>
</select>

Java Script ::

$('#count).change(function() {

                document.getElementById('loginmodal').click();
                $('#modaltrigger').leanModal({ top: 110, overlay: 0.45, closeButton: ".hidemodal" });


                  });

但它不适合我。可以帮我一个人吗?

1 个答案:

答案 0 :(得分:1)

基于这个答案

jQuery get value of select onChange

上的这个

How to open a Bootstrap modal window using jQuery?

它应该是这样的:

$('#count').change(function()
{
    if (this.value == 'c')
    {
         $('#loginmodal').modal('show');
    }
});