JQuery Getting Dynamically Created Select Value
<p>I have been reviewing a lot of pages about this and can't seem to figure out why this isn't working. </p>

<p>In an HTML page I am using PHP to dynamically create a dropdown box on the page like this:</p>

<pre><code>$sel = '&lt;select "id"="userPhones"&gt;';

foreach ($user_phones as $single_phone) 
{
$phoneId = $single_phone['id'];
$phoneNum = $single_phone['phone_num'];
if($single_phone['isdefault']=='1')
{
    $sel.="&lt;option id=".$phoneId." selected='selected'&gt;".$phoneNum."&lt;/option&gt;";
}
else
{
    $sel.="&lt;option id=".$phoneId."&gt;".$phoneNum."&lt;/option&gt;";
}
}
$sel .='&lt;/select&gt;';
echo $sel;
</code></pre>

<p>I see the dropdown appear on the page without a problem and it all looks like it is working. But then later I try to use JQuery to get at the value of the dropdown to act on it by doing this:</p>

<pre><code>phone_num = $('#userPhones :selected').val();
alert(phone_num);
</code></pre>

<p>For some reason whenever I try to get at the value I am getting an alert of "undefined" and not the value of the dropdown. I am sure this is being set because I have looked at he source of the page and I have checked with Firebug that the elements exist on the page. I have tried just using the ID of the dropdown and val(), I have tried using text() but cannot seem to grab anything. Can someone please tell me what on earth is going on here? I have been racking my brains about this for a while now. </p>
