开发者

jquery Drop down select value

开发者 https://www.devze.com 2023-01-21 03:16 出处:网络
html += \"<table><tr><td> <label for=\'id_first_name\' ><b&开发者_如何学Pythongt;Timezone:</b></label> </td>\";

   html += "<table><tr><td> <label for='id_first_name' ><b&开发者_如何学Pythongt;Timezone:</b></label> </td>";
   html += '<td><select id="timezone" name="nodes" style="width:300px;margin:5px;">';
   {% for tz in all_timezones %}
   if('{{tz}}' == 'Asia/Calcutta')
        html+='<option value="{{tz}}" selected>{{tz}}</option>';
   else
        html += '<option value="{{tz}}">{{tz}}</option>';
   {% endfor %}
   html += '</select>';
   html += "</td> </tr>";
   </script>

Now when i want to edit ,i know the previous value stored .And lets say that as Asia/Bangkok how to get this value selected an example

    var edit_val="Asia/Bangkok"

    $("#timezone selected val[edit_val]")//Sumthing like this

     In the drop downlist i want this value to be selected


Try putting this below you dropdown:

<script type="text/javascript">
   document.getElementById('timezone').value = 'Asia/Bangkok';
</script>

Let's know if that helps.

0

精彩评论

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