[英]I want to add some textboxes on selecting option from select menu in my PHP Page. This should be Dynamically(without reloding page)
On changing options from select menu the no of text boxes should be changed without reloading the page. 从选择菜单更改选项时,应在不重新加载页面的情况下更改任何文本框。
<select id="options">
<option >Select</option>
<option value="first_div">first_div</option>
<option value="second_div">second_div</option>
<option value="third_div">third_div</option>
<option value="fourth_div">fourth_div</option>
<option value="fifth_div">fifth_div</option>
</select>
I used following Sample Jquery code. 我使用了以下示例Jquery代码。 on selecting any option it goes to display div. 选择任何选项时,它将显示div。 But i want that if i select another option the another div should appears and previous should be removed. 但是我希望,如果我选择另一个选项,则另一个div应该出现,并且以前的应该删除。
$(function()
{ var selector =
{ options : '#o1'
} $('#options').bind('change', function()
{ var h = $(this).val();
if (h)
{ $(selector[$(this).attr('id')]).find('> o1').each(function()
{ $(this).toggle(h == $(this).data('select-value'))
.attr('disabled', (h != $(this).data('select-value')));
});
$(selector[$(this).attr('id')]).find('option:visible').eq(0).attr('selected', true);
$(selector[$(this).attr('id')]).show();
} });
});` $(function()
{ var selector =
{ options : '#o1'
} $('#options').bind('change', function()
{ var h = $(this).val();
if (h)
{ $(selector[$(this).attr('id')]).find('> o1').each(function()
{ $(this).toggle(h == $(this).data('select-value'))
.attr('disabled', (h != $(this).data('select-value')));
});
$(selector[$(this).attr('id')]).find('option:visible').eq(0).attr('selected', true);
$(selector[$(this).attr('id')]).show();
} });
});`
Its working to me.. 它对我有用。
$(function() {
var selector = {
options : '#o1'
}
$('#options').bind('change', function() {
var h = $(this).val();
if (h) {
$(selector[$(this).attr('id')]).find('> o1').each(function() {
$(this).toggle(h == $(this).data('select-value'))
.attr('disabled', (h != $(this).data('select-value')));
});
$(selector[$(this).attr('id')]).find('option:visible').eq(0).attr('selected', true);
$(selector[$(this).attr('id')]).show(); }
$(function() {
var selector = {
options : '#o1'
}
$('#options').bind('change', function() {
var h = $(this).val();
if (h) {
$(selector[$(this).attr('id')]).find('> o1').each(function() {
$(this).toggle(h == $(this).data('select-value'))
.attr('disabled', (h != $(this).data('select-value')));
});
$(selector[$(this).attr('id')]).find('option:visible').eq(0).attr('selected', true);
$(selector[$(this).attr('id')]).show(); }
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.