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

98
Views
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 answers
Answer question

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 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!