0

I have been trying to pop up a modal from

enter image description here

Whenever user select option c from drop down menu enter image description here

Code Snap:: Modal Form

<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>

Drop Down menu::

<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" });


                  });

but its not working for me .Can some one help me into this?

nand
  • 517
  • 2
  • 13
  • 29
  • Are errors thrown? Code shown has obvious syntax problem as witnessed by the code highlighting. Is code wrapped in a `document.ready` handler? – charlietfl Oct 10 '15 at 20:35

1 Answers1

1

Based on this answer

jQuery get value of select onChange

and this on

How to open a Bootstrap modal window using jQuery?

it should be something like this:

$('#count').change(function()
{
    if (this.value == 'c')
    {
         $('#loginmodal').modal('show');
    }
});
Community
  • 1
  • 1
ymz
  • 6,602
  • 1
  • 20
  • 39