开发者

add new line ' ' automatic to option of selecte

开发者 https://www.devze.com 2023-02-16 09:20 出处:网络
XML <?xml version=\"1.0\" encoding=\"utf-8\"?> <Questions> <Question> <Id>1</Id>

XML

<?xml version="1.0" encoding="utf-8"?>
<Questions>
  <Question>
    <Id>1</Id>
    <Text>aaa</Text>
  </Question>
</Questions>

function PopupUserRegist() {
 $.ajax({   
    type: "GET",
url: "Administrator/Questions.xml",
    success: parseXml
 });



function parseXml(xml)
{        
  $(xml).find("Question").each(function()
  { 
    var value=$(this).find('Text').text()
      $('#<%=sctQuestion.ClientI开发者_运维技巧D %>').
      append($("<option></option>").
      attr("value",value).
      text(value)); 
    });
 }

 $("#div_userregist").dialog("open");

}

HTML MainMaterPage.aspx

<select runat="server" id="sctQuestion">
<option></option>

This code Automatically Add New Line Content ' ' to option of <select>

select:row 1==' '

select:row 2=='aaaa'

how remove ' ' in first row select

$("#<%=sctQuestion.ClientID %>").removeOption(0);

error say:.removeOption(0); is not a function


You have to clear the list before you start appending:

 $('#<%=sctQuestion.ClientID %>').empty()


<select runat="server" id="sctQuestion">

for this <option></option> add ' ' to select

0

精彩评论

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