Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda