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

169
Views
How to make a new input field appear after choosing one option from a dropdown

I have to make a form with some input options and one of them being a Type Switcher (dropdown) that shows me some options and depending on the option I choose it has to appear a new input for me to write that info. This is a project in PHP, MySQL, HTML and CSS. I can use JS, Jquery, React but for the PHP U need to use OOP aproach.

Example:
Type Switcher (Car / Bike / Truck) <-- this being my 3 options of a dropdown.

If I choose car, I need a new inputfield to put the model of the car. If I choose Bike, I need a new inputfield to put the model of the bike.

Example if I choose a car:
Type Switcher: CAR
Car model:
please provide the model of the car

My switcher:

<div class="type-switcher">
  <div class="input-wrapper">
     <label for="productType">Type Switcher</label>
        <select name="Select Type" id="productType" >
        <option value="car">car</option>
        <option value="truck">truck</option>
        <option value="bike">bike</option>
     </select>
  </div>
</div>

by selecting car for example, I need to appear a new input bar with some label "please provide the model of the car" so I can write the model of the car

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

0

you can add input field using js

html

    <div class="type-switcher">
        <div class="input-wrapper">
           <label for="productType">Type Switcher</label>
              <select name="Select Type" id="productType" onclick="addField()" >
              <option value="car">car</option>
              <option value="truck">truck</option>
              <option value="bike">bike</option>
           </select>
        </div>
        <div id="text"></div>
      </div>
    
  <script src="index.js"></script>

js

const field=document.getElementById('text');
const model=document.getElementById('productType')
function addField(){
    let html=`<label>${model.value} Model:</label><input type="text"></input>`
    field.innerHTML=html;
}
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!