开发者

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 ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜