Tengo una tabla con 3 campos de texto. Quiero agregar los mismos campos de texto al hacer clic en la casilla de verificación. Tengo el siguiente código. ¿Cómo puedo hacerlo con php y 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>";Sería genial si pudiera aclarar dónde desea agregar qué campos de texto cuando se marcó la casilla de verificación.
Dos ideas:
Ejemplo de código para la segunda opción:
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 }