【问题标题】:On specific option selection from drop down menu a modal form should pop up在从下拉菜单中选择特定选项时,应弹出一个模态表单
【发布时间】:2015-10-11 04:43:10
【问题描述】:

我一直在尝试从

弹出一个模式

每当用户从下拉菜单中选择选项 c

代码快照:: 模态形式

<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 脚本 ::

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

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


                  });

但它对我不起作用。有人可以帮我解决这个问题吗?

【问题讨论】:

  • 是否抛出错误?代码高亮显示的代码存在明显的语法问题。代码是否包含在 document.ready 处理程序中?

标签: javascript jquery html


【解决方案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');
    }
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-27
    • 1970-01-01
    • 2016-09-27
    • 1970-01-01
    • 1970-01-01
    • 2014-02-23
    • 1970-01-01
    相关资源
    最近更新 更多