outdoor checkboxes indicate completion

Whenever I click on the email address example [email protected], my first checkbox gets checked inexplicably... I have created a fiddle to demonstrate this issue...

http://jsfiddle.net/pZ8jY/

<table class="checkboxes">
   <tr>
    <td >
    <label for="CheckBoxOne"><input id="CheckBoxOne" type="checkbox"  value=" <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ee9a8b9d9aae838f8782c08d8183">[email protected]</a> " />
        <span><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0d79687e794d606c6461236e6260">[email protected]</a> </span></label></td>

          <td >
    <label for="CheckBoxOne"><input id="CheckBoxOne" type="checkbox"  value=" <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="374352444305775a565e5b1954585a">[email protected]</a> " />
        <span><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aadecfd9de98eac7cbc3c684c9c5c7">[email protected]</a> </span></label></td>
  </tr>
</table>

CSS

.checkboxes label
{ 
    display: block;
    float: left;
    padding-right: 10px;
    white-space: nowrap;

}

.checkboxes input
{ 
    vertical-align: middle;
}

.checkboxes label span
{
    vertical-align: middle;

}

Answer №1

Each identifier should be distinct.

<input id="CheckBoxTwo" type="checkbox"  value=" <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="036766609283457477663b7c46401d">[email protected]</a> " />

Answer №2

Avoid using the same id multiple times. For unique checkboxes, be sure to assign different Id's. Labels function in a way that when you click on the text within the label, The action is applied to the corresponding input field. In your current code, both labels are pointing to the same id. Clicking on "test" and "test2" will affect the first visible input element with the id "CheckboxOne" in the source code, causing it to only check the first checkbox.

Furthermore, if you plan to submit this form data, remember to use the attribute "name" instead of id.

Answer №3

Consider repositioning the checkboxes outside the label and providing distinct ids

<table class="checkboxes">
  <tr>
    <td >
      <label for="CheckBoxOne"><span><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f581908681b598949c99db969a98">[email protected]</a> </span></label>
      <input id="CheckBoxOne" type="checkbox"  value=" <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cabeafb9be8aa7aba3a6e4a9a5a7">[email protected]</a> " />
    </td>
    <td >
      <label for="CheckBoxOne2"><span><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f98d9c8a8dcbb994989095d79a962a97969692fd94">[email protected]</a> </span></label>
      <input id="CheckBoxOne2" type="checkbox"  value=" <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3a4e5f494e087a575b535614595557">[email protected]</a> " />
    </td>
 </tr>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for maintaining knowledge after redirecting to a new page

Building an app using Ionic 4 where I need to display vouchers from a database as images. Each image should act as a link to a details page showing more information about that specific voucher. However, I am struggling to figure out how to keep track of th ...

Switching back and forth between classes prevents the animation from playing continuously, causing it to jump straight to the end

Currently, I am in the process of animating a hamburger menu with a unique twist. The idea is to have the top and bottom lines smoothly translate to the middle and then elegantly rotate into an X shape when clicked. My approach involves toggling between tw ...

Issues with @font-face and @font-family not being recognized

I've been attempting to achieve a simple task: adding 3 different fonts to an HTML page. After browsing through numerous examples, I still haven't found a solution to my issue. It's possible that I may be missing something in how it's ...

Which HTML tag should I choose to apply color to text in Twitter Bootstrap?

I'm looking to enhance the appearance of a specific word in my text. For example: This is my text, <span class="red">this</span> should be red. Would using the span tag be the appropriate method for achieving this effect? Or are there ot ...

Maintaining the format of forms input in Rails and HTML: Tips and tricks

Hey there! I'm working on a Rails app that has a simple HTML form. One of the fields is called description, which is a text_area. I want to be able to display its input exactly as it was entered on the index page. For instance: If someone enters a l ...

The true meaning of CSS3 transition is often misconstr

I'm trying to create a simple linear transition effect, but for some reason it's not working. Any suggestions on what might be causing the issue? HTML <div class="button-modern" style="background-color:#e73032"> <span style="color: ...

Is there a way to rigorously validate my HTML, CSS, and JavaScript files against specific standards?

Can modern browsers suppress errors in HTML, CSS, and JS sources? Is there a method to uncover all mistakes, no matter how small they may be? ...

Adjusting the width of a div element horizontally in Angular 4 and

As someone new to Angular 4, I've been attempting to create a resizable div (horizontally) without success. My goal is to be able to click and drag a grabber to resize the text area horizontally. However, in the example provided in the link below, the ...

Tips for enabling resize functionality on individual components one at a time

Check out my Codepen link for the resizable event While using Jquery UI resizable, everything is functioning correctly. However, I am now looking to have the resizable event activate one block at a time. When another block is clicked, the resizable event ...

Import JSON Data into Angular-nvD3 Chart (AngularJS)

I am seeking help to load encoded JSON Data retrieved from a database via queries into an Angular-nvD3 graph. I am unsure about the best approach to achieve this task. The encoded JSON data is fetched using API queries from a database table called PRODUCT ...

Eliminating elements that adjust according to different screen sizes

Website: I am currently working on customizing a Tumblr theme I downloaded by removing some responsive elements. The rollover effects I created are being affected when the screen size goes below 1024px, and I am not happy with how it looks. Additionally, ...

The HTML website appears to be having trouble scrolling on Android devices, however, it functions properly on both iOS and desktop platforms

Hello everyone, I need help solving an issue with my responsive HTML website. It works perfectly on a desktop browser, but when viewed on a mobile device, it gets stuck and won't scroll. Any suggestions on what might be causing this problem? Thank you ...

What is the process for establishing the admin's username and password using a database table?

I recently developed a website that includes a login form for the administrator. I have set up an admin table in my database and filled it with values. However, when I attempt to log in, the password is not being recognized. Here is a snapshot of my curren ...

Change the color of the menu icon based on the specified HTML class or attribute

I'm trying to create a fixed menu that changes color depending on the background of different sections. Currently, I am using a data-color attribute but I am struggling with removing and adding the class to #open-button. Adding the class works fine, ...

Variations in browser rendering of SVGs as CSS list-style-images

After creating a simple SVG of a red circle to serve as the list-style-image for my website, I discovered the concept in this Stack Overflow response: The solution worked seamlessly across all browsers except Internet Explorer. In IE, the SVG image render ...

Ways to move down only one level of an element's children, excluding sub-levels

When implementing this code snippet: jQuery: $(this).next().slideDown() with a selector :$(this).next() HTML: <li class="sub-menu two-level-collapse"> <a href="javascript:void(0);" class="two-level-collapse parent">< ...

Delivering Access data in HTML format via email

In my MS Access database, I have a report that combines client records from one table (including email addresses) with grouped records fetched from other tables using a Query. I want to send this report directly to each client via email, within the body o ...

Encountering overlap issues when applying labels to my flexbox using the Spectre framework in CSS

I need help creating a "hat" with two textarea columns using the spectre.css framework. My goal is to have these columns resize based on the screen size, stacking on top of each other when the screen size is below 600px. I can achieve this without any issu ...

Ways to initiate a flip motion

Looking for a way to create a flip image effect when clicked by the user. Here is the code I have so far: let img = document.querySelector('img') let div; let click = 0; img.onclick=function(){ console.log(click) if(click %2 ==0){ d ...

Full width display without any scrollbars

I need some help with adjusting the width of a section on my webpage to fit the browser size. Currently, I am using width: 100%, but this is causing scrollbars to appear. Unfortunately, I can't use overflow-x: hidden; as it will hide some of the conte ...