簡體   English   中英

如果有多個復選框,如何選中/取消選中特定復選框

[英]how to check/uncheck only specific checkbox if there are multiple checkboxes

<div style="height: 237px; margin-top: 5px; overflow-y: scroll;width:230px;" id="divContainer">
    <input type="checkbox" value="anxyzkur@xyz.com" class="ads_Checkbox" name="chk_[18510][email]" checked="" id="chk_">   
   <label style="position: relative;vertical-align:text-bottom;" for="chk_">item 25</label>
    <p style="padding-left:25px;margin-top:0;width:170px;" id="address">Ahmedabad</p>

    <input type="checkbox" value="abc@abc.com" class="ads_Checkbox" name="chk_[18549][email]" checked="" id="chk_">
     <label style="position: relative;vertical-align:text-bottom;" for="chk_">item3</label>
      <p style="padding-left:25px;margin-top:0;width:170px;" id="address">ahmedabad</p></div>

http://jsfiddle.net/Urvisha123/ZCTNe/請看這個小提琴。

我有問題,當我點擊第二個標簽復選框。然后第一個復選框是選中/取消選中。

我不想要這個。

兩個復選框都有相同的ID,標簽屬性“for”更改這些

<input type="checkbox" value="abc@abc.com" class="ads_Checkbox" name="chk_[18549][email]" checked="" id="chk_"><label style="position: relative;vertical-align:text-bottom;" for="chk_">item3</label>

<input type="checkbox" value="abc@abc.com" class="ads_Checkbox" name="chk_[18549][email]" checked="" id="chk__"><label style="position: relative;vertical-align:text-bottom;" for="chk__">item3</label>

如果你動態構建這些,那么它應該是這樣的

<?php

for( $i=0; $i < 10 ; $i++)
{
?>
<input type="checkbox" value="abc@abc.com" class="ads_Checkbox" name="chk_[18549][email]" checked="" id="<?php echo 'chk_'.$i;?>">
<label style="position: relative;vertical-align:text-bottom;" for="<?php echo 'chk_'.$i;?>">item3</label>

<?php
}
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM