简体   繁体   中英

How to call a jQuery Colorbox pop up on the onchange event of select HTML control?

Following is my code snippet:

    <select  name="select_option">
      <option value="0">--Select Action--</option>
      <option value="1" class="delete_bulk_tests">Delete User</option>
      <option value="2" class="disable_bulk_tests">Disable User</option>
    </select>
    <div class="hidden">
      <div id="deletePopContent" class="c-popup">
        <h2 class="c-popup-header">Delete Users</h2>
        <div class="c-content">         
          <h3>Are you sure to delete selected users?</h3>
          <p class="alert"><strong>You are about to perform an action which can't be undone</strong></p>
          <a href="#"class="c-btn">No</a><a href="#"class="c-btn" id="delete_url">Delete</a> 
        </div>
      </div>
    </div>
<div class="hidden">
      <div id="disablePopContent" class="c-popup">
        <h2 class="c-popup-header">Disable Users</h2>
        <div class="c-content">         
          <h3>Are you sure to disable selected users?</h3>
          <p class="alert"><strong>You are about to perform an action which can't be undone</strong></p>
          <a href="#"class="c-btn">No</a><a href="#"class="c-btn" id="disable_url">Disable</a> 
        </div>
      </div>
    </div>

    $(document).ready(function()  {
    $(".delete_bulk_tests").onchange(function(e) { 
        $(".delete_bulk_tests").colorbox({inline:true, width:666});

    });

$(".disable_bulk_tests").onchange(function(e) { 
        $(".disable_bulk_tests").colorbox({inline:true, width:666});

    });
  });

I want to display the corresponding colorbox upon selection of concerned option. I tried as above but not able to call the Colorbox with id deletePopContent and disablePopContent . I've included all the necessary libraries and also there is no errror or warning coming in the firebug console. Can anyone help me in displaying the colorbox?Thanks in advance.

Use the below code:

$(document).ready(function()  {
    $(".delete_bulk_tests").change(function(e) { 
        $(this).colorbox({inline:true, width:666});

    });

$(".disable_bulk_tests").change(function(e) { 
        $(this).colorbox({inline:true, width:666});

    });
  });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM