views:

29

answers:

1

   html += "<table><tr><td> <label for='id_first_name' ><b>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
+1  A: 

Try putting this below you dropdown:

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

Let's know if that helps.

Sarfraz
@sarfraz: When i edit i know the old timezone value that is stored in the database.How to populate the old value and make it selected
Rajeev
@Rajeev: To make it selected, replace `Asia/Bangkok` with your value as shown in my answer.
Sarfraz