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

115
Views
jQuery for showing different text field showing when select two different items in selectbox

How to display the text fields when choosing different option from the selectoption (if select USA option USA text field need to show)?

<select name="cntry"> 
<option value="us">USA</option>
<option value="uk">uk</option>
</select >
<input type="text" value="USA" name="USA">
<input type="text" value="UK" name="UK">
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

$('#country').on('change', function() {
  $('input').each(function() {
    $(this).css('display', 'none');
  });
  if (this.value === 'us') {
    $('input[name="USA"]').css('display', 'initial')
  }
  if (this.value === 'uk') {
    $('input[name="UK"]').css('display', 'initial')
  }
});
input {
  display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id="country" name="cntry">
  <option selected disabled hidden>Select your Country</option>
  <option value="us">USA</option>
  <option value="uk">uk</option>
</select>
<input type="text" value="USA" name="USA">
<input type="text" value="UK" name="UK">

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!