jquery Drop down select value
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.
精彩评论