开发者

Appending Item to dropdown list without selecting the item

I have a form wherr I开发者_JAVA百科 fill in an item name and immediately after I hit submit the item adds to the select dropdownlist and is automatically selected. Is there a way not to have this newly added item selected?

My code that adds the item looks like this

$("#userGroup_groups").append("<option value="41" selected="selected">item</option>");


remove selected

$("#userGroup_groups").append("<option value=\"41\" >item</option>");


Don't set the new items selected property

$("#userGroup_groups").append('<option value="41">item</option>'); 


check page post back on page_load event and set AutoPostBack="true" in asp:ddl control

  if (!IsPostBack) {
                LoadInfoDDL();
            }

so this will only resolve your problem.


You must use combination of the " and ' while doing things like this

$("#userGroup_groups").append(
    "<option value='41' selected='selected'>item</option>"
);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜