开发者

Un able to Set value to asp DropDownlist using jquery

开发者 https://www.devze.com 2023-02-25 00:01 出处:网络
I am using jquery-1.4.4. i am trying to set value of dropdown list using jquery way in internet explorer 6.

I am using jquery-1.4.4. i am trying to set value of dropdown list using jquery way in internet explorer 6.

$('#ddlDistricts').val(SetValueL);

if i take the count of items inside the dropdown list it is showing 3 items and it is working fine with ie开发者_运维问答7,8 and firefox4.0.

Please tell me how we select the dropdownlist item with value in ie6 using jquery.

Thanks in advance Rajeev


Set value as given below:

JQUERY:

$(document).ready(function(){
  //adding state dynamic.
    var zIdL = "1";var zDisplayMemberL = "State1";
    $("#ddlStates").append($("<option></option>").val(zIdL).html(zDisplayMemberL));
    zIdL = "2";zDisplayMemberL = "State2";
    $("#ddlStates").append($("<option></option>").val(zIdL).html(zDisplayMemberL));
    zIdL = "3";zDisplayMemberL = "State3";
    $("#ddlStates").append($("<option></option>").val(zIdL).html(zDisplayMemberL));
    //now take the state id
    var SetValueL = "2";
    //now we set the value
    $("#ddlStates").val(SetValueL);
});

HTML:

<table border="1">
    <tr> 
        <td align="right"> State: </td> <td align="left"> 
        <select name="ddlStates" id="ddlStates" style="width:200px;">
        </select> </td> 
    </tr> 
</table>

CLICK HERE TO SEE THE DEMO

0

精彩评论

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

关注公众号