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

100
Vistas
Adding new input fields on check box ticked

I have a table with 3 text fields i want to add the same text fields on clicking check box i have the following code how can i do it with php and javascript

 echo "<td>Screen ".$i."</td>";
                       echo "<td><input type='text' id='filmname".$k."' name='filmname".$k."'value='".$prefilm."'></td>";
                       echo "<td><input type='text' id='Language".$k."' name='Language".$k."'value='".$prelang."'></td>";
                       echo "<td><input type='text' id='showtime".$k."' name='showtime".$k."'value='".$prescreen."'></td>";
                       
 echo "<td ><input type='checkbox' class='Checkbox' id='addshow".$k."' autocomplete='off'
                       name='addshow".$k."' value='addshow' onclick='addshow(".$k.")</td>";                       
                       

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

0

It would be great if you can clarify where you want to add which text fields when the checkbox got checked.

Two ideas:

  1. You can create your text fields at the same time when you create your table and then hide/show them with CSS and JavaScript. (Preferred)
  2. Add a click listener to your checkbox and create your text fields dynamically with JS with document.createElement('input') Learn more here

Code examaple for the 2nd option:

const check = document.querySelector('input[type=checkbox]');
      check.addEventListener('click', createTextInput);

function createTextInput() {
  const target = document.querySelector(YOUR TARGET SELECTOR);

  const input = document.createElement('input'); 
        input.setAttribute('type', 'text');
        input.addEventListener(OPTIONAL IF YOU WANT)

  target.appendChild(input); // this adds the new input into your target
}

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