Can anyone help with this? It appears to have been overlooked. The
title should really have been "changing the selected item in a
dropdown" (perhaps) because I know how to do the append, I just can't
get my head around how to modify the existing items in the list. Will
it be easier to rebuild the list?

On Apr 3, 6:22 pm, LinkGuru <[email protected]> wrote:
> With the following code, I'm managing to append to a drop-down list
> using jQuery, but can't figure out how to amend one of the existing
> items in the drop down so it is not the selected one i.e. I only want
> the one that's appended to be the selected one.
> Can anyone help?
> Here is the simplified code.
>
>                 $(".actionOptAdd").bind("click",
>                         function()
>                         {
> .
> .
> .
>                                 $.getJSON('lib/addToProj.php',
>                                 {....}, function(data)
>                         }, function(data)
>                                 {
>                                    $.each(data, function(i,item)
>                                    {
>                                             if ( i == "project" )project=item;
>                                             if ( i == "insertid" 
> )insertid=item;
>                                    });
>                                    var drp = $('#dropdown');
>                                    drp.append("<optionvalue='"+insertid+"'
> selected='selected'>"+project+"</option>");
>                                    });
>                         }
>                 );
> //Thanks in advance.

Reply via email to