|
|
|
| Всем привет. Есть текстовое поле, селект и кнопка. Вводим текст в текстовое поле и жмем на кнопку и эта запись вносится в селект. Как сделать, чтобы не вносились дубли?
<script type="text/javascript">
$(function(){
$('#history_btn_add').click(function(){
$('#history_select').append('<option val="'+$('#history_input_add').val()+'">'+$('#history_input_add').val()+'</option>');
$('#history_input_add').val('').focus();
});
});
</script>
|
| |
|
|
|
|
|
|
|
для: TetRiska
(17.12.2011 в 23:09)
| | получилось реализовать! :) вот кому надо будет
<script type="text/javascript">
$(function(){
$('#history_btn_add').click(function(){
var pres = 0;
$('#history_select option').each(function(){
if($('#history_input_add').val() == this.text){
pres=1;
return false;
}
});
if($('#history_input_add').val() != '' && pres == 0){
$('#history_select').append('<option val="'+$('#history_input_add').val()+'">'+$('#history_input_add').val()+'</option>');
$('#history_input_add').val('').focus();
}
});
});
</script>
|
| |
|
|
|