Adding values from a list of checkboxes to a textbox
<p>I am new to jQuery, so I am not familliar with syntax of it.</p>

<p>The problem I am facing right now is, I have a dropdown list with some values and corresponding checkboxes. When someone selects a particular value from the dropdown i.e checks a checkbox from dropdown, I want to add the 'value' of the checkbox to the textbox which is besides the dropdown of checkboxes.</p>

<p>The code I have come up with is</p>

<pre><code>$(".productr-dropdown li input[type='checkbox']").click(function(e){
        var cmd = $(this).val();
        addToTextBox(cmd);
});  

function addToTextBox(cmd){
    command = $(".z:eq(2)").find("#platform_Command").val();

    if (command.indexOf(' '+cmd+' ')&gt;=0)
        return;
    else {
        // THIS IS THE NEXT PART WHERE I AM STUCK
        // I don't know how to add/replace the contents of 'cmd' 
        //  to the contents of 'command'(which is the value of the textbox)    
    }       
}
</code></pre>

<p>To better explain my problem I will write a use case here,
The user checks a checkbox from the dropdown, e.g the value of the checkbox checked is 'abc', the textbox in which I want to add this 'abc' already has a value say 'xyz hijkl defg'. what should happen is the value'abc' should get added to the textbox in such a way that the value of the textbox would be'xyz abc hijkl defg' </p>

<p>The problem I have is I am not sure whether I am invoking the correct event also.</p>

<p>One more approach I have in mind is,
$(document).click(function(e) {
        $(".productr-dropdown").hide();
        $(".productr-dropdown").each(["input='checkbox':checked"], function (e){
            addToTextBox($(this).val());
        });
    });</p>

<p>Which one is better ?</p>

<p>What is the syntax to only select values in the dropdown which are checked ?</p>
