简体   繁体   中英

Displaying a text field only if a particular value is selected

I've created a dropdown list that contains 3 values:

  • date wise
  • active students
  • inactive student

How can I select a text field asking what the date of birth of the user is, if and only if the person has selected the "date" field?

Please provide us with more information, and take a look at the jquery ui datepicker.

http://jqueryui.com/demos/datepicker/

This might be what you're looking for:

http://api.jquery.com/change/

http://api.jquery.com/show/

http://api.jquery.com/hide/

If you're not familiar with jquery, just take a closer look at the examples on those pages and you should be good to go:)

//edit - example:

  <select id="filter_selection">
    <option value="date_wise">Date Wise</option>
    <option value="active_students">Active Students</option>
    <option value="inactive_students">Inactive Students</option>
  </select>

<span id="text" style="display: none"><input type="text" name="text"></span>

<script>
$('#filter_selection').change(function() {
  if($(this).val == 'date_wise') {
    $('#text').show();
  } else { 
    $('#text').hide(); 
  }
});
</script>

...untested;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM