Changing Selected Option Select menu .attr
<p>I am trying to pre-fill a form that containes select menu's, using JSON, i am using the key as the #id tags for the select menu's
but i cant seem to get it to work i have tried different selectors but still no luck,</p>

<p>here is my code</p>

<pre><code> $(document).ready(function () {

     var p = {
         "weight":"39",
         "height":"1.24",
         "age":"34"
     };

     for (var key in p) {
         if (p.hasOwnProperty(key)) {

             if ($("#" + key + " option [value=" + p[key] + "]").length) {
                 $("#" + key + " option [value=" + p[key] + "]").attr('selected', 'selected');
             }

         }
     }
 });

 &lt;select id="age"&gt;
 &lt;option value="33"&gt;33&lt;/option&gt;
 &lt;option value="34"&gt;34&lt;/option&gt;
 &lt;/select&gt;

 &lt;select id="height"&gt;
 &lt;option value="1.25"&gt;1.25&lt;/option&gt;
 &lt;option value="1.24"&gt;1.24&lt;/option&gt;
 &lt;/select&gt;

 &lt;select id="weight"&gt;
 &lt;option value="38"&gt;38&lt;/option&gt;
 &lt;option value="39"&gt;39&lt;/option&gt;
 &lt;/select&gt;
</code></pre>
