0

I want to update p_fullname and put data into multiselect dropdownbox using below function:

function update_project_group(pg_id,pg_group_name,p_fullname){
        document.getElementById('pg_id').value=pg_id;
        document.getElementById('group_name').value=pg_group_name;
        document.getElementById('projectmember').value=p_fullname;

        var array = p_fullname;
        var dataarray=array.split(",");
        $("#projectmember").val(dataarray);
        $('#projectmember').multiselect( 'settings', { columns: 2}); 
    }

1 Answers1

0

I think the answer could be found here.

Html

<select name='strings' id="strings" multiple style="width:100px;">
    <option value="Test">Test</option>
    <option value="Prof">Prof</option>
    <option value="Live">Live</option>
    <option value="Off">Off</option>
    <option value="On">On</option>
</select>

javaScript

var values="Test,Prof,Off";
$.each(values.split(","), function(i,e){
    $("#strings option[value='" + e + "']").prop("selected", true);
});

And here is a working example: http://jsfiddle.net/McddQ/1/

Masoud Darvishian
  • 3,080
  • 4
  • 27
  • 37