简体   繁体   English

单击图标时,出现一个带有复选框列表的弹出窗口

[英]Have a pop up window with checked box list when click on an icon

I have a table in my page, for which I get the data from database. 我的页面中有一个表,我从数据库中获取数据。 In some cells I have an edit icon.I want when users clicks on it, they see a pop up window. 在某些单元格中,我有一个编辑图标。当用户单击它时,我希望他们看到一个弹出窗口。

In the pop up window, I want to show three option(check boxes), that user can select only one of them, and then click on OK button, and return the value of the selected option to the data variable.(as you see in the code below) 在弹出的窗口中,我要显示三个选项(复选框),该用户只能选择其中一个,然后单击“确定”按钮,然后将所选选项的值返回到数据变量。(如您所见)在下面的代码中)

I have to mention, that right now when the user clicks on the edit icon, some information are sent to another file. 我不得不提到,当用户单击编辑图标时,一些信息将发送到另一个文件。 Because I need to update database. 因为我需要更新数据库。

   $(".SSO").click(function () {
    var id = $(this).attr("data-id");
    var data= HERE I NEED TO GET THE VALUE OF THE SELECTED OPTION IN THE POP UP WINDOW
  }

So SSO is the value of class attribute for the image icon. 因此,SSO是图像图标的class属性的值。 data-id value helps to update the correct record in the database. data-id值有助于更新数据库中的正确记录。

Right now this is the code in one file: 现在,这是一个文件中的代码:

 $(".SSO").click(function()

 {
   var id = $(this).attr("data-id");
   // open popup window and pass field id
   window.open('sku.php?id=' + encodeURIComponent(id),
       'width=400,toolbar=1,resizable=1,scrollbars=yes,height=400,top=100,left=100');
}

and this is the code in sku.php 这是sku.php中的代码

  <script type="text/javascript">
        function sendValue (s){
          var parentId = <?php echo json_encode($_GET['id']); ?>;
          window.opener.updateValue(parentId, s);
          window.close();
          window.close();
        }
        </script>

        <form name="selectform">
        <input type=button value="OK" onClick="sendValue(document.querySelector('.messageCheckbox:checked').value);"
       </form>

Mu form right now has only OK button, when when I click on teh edit button, nothing happens. Mu表格现在只有一个“确定”按钮,当我单击“编辑”按钮时,什么也没有发生。 Should not I see a pop up window, with OK button inside it? 我是否应该看到其中包含“确定”按钮的弹出窗口?

Typically a popup windows is shown with alert() or something similar, which causes the browser to make an actual popup window. 通常,弹出窗口会显示有alert()或类似内容,这会导致浏览器生成实际的弹出窗口。 That kind of popup window cannot have HTML elements added to it. 这种弹出窗口不能添加HTML元素。 You could do something like this http://www.codeproject.com/Tips/170049/Pure-HTML-CSS-Modal-Dialog-Box-no-JavaScript 您可以执行以下操作:http://www.codeproject.com/Tips/170049/Pure-HTML-CSS-Modal-Dialog-Box-no-JavaScript

I used those in a website and I liked them a lot, but I am not a fan of the css :target selector, so I opened it with Javascript instead, but it is pretty much the same thing. 我在网站上使用了它们,我非常喜欢它们,但是我不喜欢css :target选择器,因此我改用Javascript打开它,但几乎是同一回事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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