Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
How to get the values or texts from HTML select tag using JavaScript?

In my html file i have the following:

<td id="trainers_rowC1">Trainer1</td>

<td><input type="button" id="edit_button1" value="Edit" class="edit" onclick="edit_rowC('1')"></td>

In my JavaScript file i have this function:

function edit_rowC(no) {
    var trainers = document.getElementById("trainers_rowC" + no);
    var trainers_data = trainers.innerHTML;
    trainers.innerHTML = "<select id ='trainers_options" + no + "'><option value='" + trainers_data + "'>";
}

But when i press the Edit button the dropdown menu is empty. What is the mistake?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

This works for me.

Your mistake was that you tried to set the content of the option tag with value="...". But you have to write it between the two tags. --> <option>" + test + "</option>

function edit_rowC(no) {
    var test = document.getElementById("trainers_rowC" + no).innerHTML;
    document.getElementById("trainers_rowC" + no).innerHTML = "<td><select id ='trainers_options" + no + "'><option>" + test + "</option><option>test</option></select></td>";
}

about 4 years ago · Juan Pablo Isaza Denunciar

0

There doesn't seem to be any closing tags in the assignment of trainers.innerHTML - could that be it?

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda