如何将 id 复选框添加到模态框?

How to checkbox id to the modal box?(如何将 id 复选框添加到模态框?)
本文介绍了如何将 id 复选框添加到模态框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何将复选框 id 传递给模态框?

我有一个表格,每行都有一个复选框和一个按钮.每当按下按钮时,都会出现一个模态框,同时复选框也会被选中.

I have a table which each row have a checkbox and a button. whenever the button is pressed, a modal box will appear and at the same time the checkbox will get checked as well.

模式框会询问用户是否要删除特定记录.如果是,表格将被提交.如果否,复选框将被取消选中.

The modal box will as ask user if want to delete particular record. If Yes, the form will be submitted. If No, the checkbox will be unchecked.

我遇到了取消选中复选框的问题.任何人都可以帮助提供示例代码吗?如何将复选框 id 传递给模态框,以便取消选中该特定复选框?

I am facing issue with getting the checkbox unchecked. Anyone can assist with sample code? How do I pass the checkbox id to the modal box so that that particular checkbox can be unchecked?

谢谢.

     var buttons3 = $("#yns button").click(function(e) { 
    // get user input
     var yes = buttons3.index(this) === 0;
     if (yes){
     $('form#form1').submit();
     return true;
     } 
    else{
     //How to get the particular Checkbox id so that it can be unchecked? 

  $(this).dialog("close");

 return false;

 } 

});

我的模态框 Html:

My Modal Box Html:

<div class="widget modal2" id="yns"> <header>
 <h2>Confirmation</h2></header> <section>
   <p> Do you want to delete this item? </p> <!-- yes/no buttons --> <p> 
<button class="button" type="button">Yes</button> 
<button class="button" type="button">No</button> 
</p> </section> </div> 

我的表格 HTML:

<tr>                                        
   <td><input type="checkbox" id="measure<?php echo $count;?>
    " name="measureid[]" value="<?php echo $items>"></td>
    <td><?php  echo $Name;?></td>
    <td>
  <ul id="tip" class="abuttons">
    <li><a class="button"><span class="edit" title="Edit"></span></a></li>
    <li><a rel="#yns" id="unitbtn<?php echo $count;?>" class="modalInput button">
       <span class="delete" title="Delete"></span></a></li>
  </ul>
  </td>
 </tr>

Modal 和 Table 在同一个 php 页面中.

Modal and Table within same php page.

推荐答案

你的问题我不清楚,所以我假设(不是一个很好的问题)一次只选中一个复选框,所以你可以取消选中它

your question not clear to me, so i have assumed (not a very good one) that only one checkbox is checked at a moment so you can uncheck it by

$("input[name='measureid\[\]']:checked").removeAttr("checked")

它将取消选中已选中并具有 name="measureid[]" 的复选框

it will uncheck the checkbox that is checked and has name="measureid[]"

这篇关于如何将 id 复选框添加到模态框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)