2012-08-28 50 views
0

我弹出一个弹出式菜单上的下拉菜单上的特定选项 弹出我正在使用一个文本框和一个保存按钮 上点击保存按钮文本框的值被保存到数据库使用弹出式jQuery的

现在我想显示当前添加选项到下拉菜单。 我无法在下拉列表中显示它。

我用下面的代码

var myselect = $('Select'); 
       var othercountry = getValue1("txtCountry"); 
       $.each(othercountry, function (val, text) { 
        othercountry.append($('<option></option>').val(val).html(text)); 

       }) 
+1

什么getValue1办?什么id othercountry? – Ankur

+0

function getValue1(Id){ return $ .trim($('#'+ Id).val()); } –

回答

1
var option = $('<option />'); 
$('#select').append(option); 

option.val('valueToAdd').html('visibleText');