Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

314
Views
uncheck a checkbox when I check another - laravel

i have a problem, i need to uncheck a checkbox when check another checkbox. but checkboxes must not have the same name. the name field must be different.

       <input type="radio" class="new-control-input" name="custom-radio-1">

  <input type="radio" class="new-control-input" name="custom-radio-2">

How can I make them uncheck?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Using JavaScript you can do something like this:

function uncheckAndCheck(event) {

  // gets all radios with the name prefix like 'custom-radio-'
  // and uncheck all of them
  document.querySelectorAll( "input[type='radio'][name^='custom-radio-']" ).forEach( radio => {
    radio.checked = false;
  });
  
  // checks the radio that triggered the click event
  event.target.checked = true;
  
}
<input type="radio" class="new-control-input" name="custom-radio-1" onclick="uncheckAndCheck(event)"/>
<input type="radio" class="new-control-input" name="custom-radio-2" onclick="uncheckAndCheck(event)"/>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!