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

138
Views
Cómo marcar las casillas de verificación según el valor del campo de entrada

Como 1,2 o one, two marca la primera y la segunda casilla.

Necesito una solución usando Javascript o JQuery

 <input type="text" id="select" value="1,2" placeholder="type any thing"> <button id=submit> click </button> <table> <thead> <tr> <th> </th> <th> Name </th> <th> ph </th> <th> email </th> <th> reg no </th> </tr> </thead> <tbody> @foreach ($studentlist as $list) <tr> <!-- THE CHECKBOXES --> <td> <div class="checkbox p-0 mr-0"> <input type="checkbox" value="{{ $list->studentid }}" name="checkbox[]" id="checkbox-in-{{ $list->studentid }}"> <label for="checkbox-in-{{ $list->studentid }}"></label> </div> </td> <td> {{ $list->studenName }} </td> <td> {{ $list->studentphnuumber }} </td> <td> {{ $list->email }} </td> <td> {{ $list->Regno }} </td> </tr> @endforeach </tbody> </table>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

 const controlInput = document.querySelector("#select"); const checkboxes = document.querySelectorAll("input[type=checkbox]"); // Initial check check(controlInput); // Check on update controlInput.addEventListener("keyup", (e) => { check(e.target); }); /** * @param {HTMLInputElement} controlInput */ function check(controlInput) { input = cleanInput(controlInput.value); const targetCheboxesIds = input.split(","); checkboxes.forEach((box) => { if (targetCheboxesIds.includes(box.id)) { box.checked = true; } else { box.checked = false; } }); controlInput.value = input; } /** * @param {string} input */ function cleanInput(input) { // Removing white space and letters return input.replaceAll(/\s+/g, "").replaceAll(/[a-zA-Z]/g, ""); }
 <label>Students</label> <input type="text" class="form-control" id="select" placeholder="type any thing" value=",3,5"> <div> <label for="checkbox1"> 1 </label> <input type="checkbox" name="checkbox1" id="1"> </div> <div> <label for="checkbox2"> 2 </label> <input type="checkbox" name="checkbox2" id="2"> </div> <div> <label for="checkbox3"> 3 </label> <input type="checkbox" name="checkbox3" id="3"> </div> <div> <label for="checkbox4"> 4 </label> <input type="checkbox" name="checkbox4" id="4"> </div> <div> <label for="checkbox5"> 5 </label> <input type="checkbox" name="checkbox5" id="5"> </div>

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!