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

139
Views
Obtenga valores de HTML solo si la casilla marcada está marcada (HTML + secuencia de comandos de Python)

Tengo una página web con varias casillas de verificación y los valores de entrada relativos ingrese la descripción de la imagen aquí

con el siguiente código:

 <tr><td><input type=\"checkbox\" id=\"second_checkbox\" name=\"second_checkbox\" value=\"" + Sample_ID + "\"><label for=\""+ Sample_ID + "\">"+ Sample_ID +"</label><br></td><td><select name=\"option\" id=\"option\"><option value=\"\" selected=\"selected\"></option><option value=\"=\">=</option><option value=\"!=\">!=</option><option value=\">\">></option><option value=\">=\">>=</option><option value=\"<\"><</option><option value=\"<=\"><=</option><option value=\"ilike\">contains</option></select></td><td><input type=\"text\" name=\"valore\" placeholder=\"value\"></td></tr>"

y obtengo los diferentes valores usando estas funciones:

 filtri = request.form.getlist('second_checkbox') simbolo = request.form.getlist('option') valori = request.form.getlist('valore')

pero la matriz "valori" toma todos los valores vacíos en la página y quiero tomar solo los que están marcados en la primera casilla de verificación. ¿Cómo puedo hacer eso?

Gracias

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

0

Primero, elimine las identificaciones y los nombres duplicados en el html. Una identificación en html debe ser única. Usando el mecanismo de selección correcto, tampoco los necesita.

Para el lado del cliente (por lo tanto, dentro del navegador) puede seleccionar todas las casillas marcadas usando el selector [type=checkbox]:checked . Aquí hay un ejemplo reproducible mínimo .

 document.addEventListener(`click`, evt => { console.clear(); const allChecked = document.querySelectorAll(`[type='checkbox']:checked`); // ^ only checked if (allChecked.length) { return allChecked .forEach(cb => { const theRow = cb.closest(`tr`); console.log(`checked row (#${theRow.rowIndex + 1}) text input value: ${ theRow.querySelector(`input[type='text']`).value || `no value`}`); }); } return console.log(`none checked (yet)`); });
 <table> <tr> <td> <input type="checkbox" value="123"> 123 </td> <td> selector here </td> <td> <input type="text" placeholder="value" value="row 1"> </td> </tr> <tr> <td> <input type="checkbox" value="456"> 456 </td> <td> selector here </td> <td> <input type="text" placeholder="value" value="row 2"> </td> </tr> <tr> <td><input type="checkbox" value="789"> 789 <td> selector here </td> <td> <input type="text" placeholder="value" value="row 3"> </td> </tr> </table>

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!