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

165
Views
Genere una fila con celdas vacías y una lista desplegable llena

Necesito generar en JavaScript una nueva fila en una tabla con una (lista desplegable) que ya está llena y vacía otras celdas y quiero que la función funcione sin importar qué celdas sea la lista desplegable en la fila.

Aquí está mi función:

 function AddRows(tableid){ var table = document.getElementById(tableid); var tbody = table.tBodies[0]; var rowCount = tbody.rows.length; var row = table.insertRow(rowCount); var lastRow = tbody.rows[rowCount-1]; var clonedRow = lastRow.cloneNode(true); var editContent = !row.isContentEditable; row.contentEditable = editContent; row.setAttribute('onkeyup', "Disabled();"); row.setAttribute('onclick', "SetSelectedRow(this)"); row.setAttribute('id', 'Combo_row'+(row.rowIndex - 1)); //Set the id of the row row.setAttribute('class', 'default'); for(i=0; i< clonedRow.cells.length;i++){ var clonedcell = clonedRow.cells[i]; if(!clonedcell.children[0]){ clonedcell.innerText= ""; } } tbody.appendChild(clonedRow); }

Y esto es lo que obtengo: ingrese la descripción de la imagen aquí

El problema es que cuando agrego una fila, mantengo lo que agregué en la entrada y solo quiero mantener lo que está en la lista desplegable. La otra celda debe estar vacía porque quiero que el usuario inserte otra información.

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

0

¡Encontré una solución! Si alguien necesita aquí está mi función de trabajo:

 /* function to add row with a select */ // lPos : list of cells position in the row to reset function addSelect(SelectTableId, lPos) { var Table = document.getElementById(SelectTableId); // Get the table id var R = document.querySelectorAll('tbody .AddRowClass')[0]; // Get the row className var C = R.cloneNode(true); // Clone the row for (let i = 0; i< lPos.length; i++){ // Clear selected cells of the row C.children[lPos[i]].textContent = "" } Table.appendChild(C); // Display the new row with filled dropdown list and empty cells }
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!