BECAUSE YOUR OWN CODE is *changing* the array
group into a STRING on the first time through the loop!!!
Code:
group = "<option value='"+group[number]+"'>"+group[number]+"</option>";
After the first such assignment,
group is now a string, and so then when you use
group[number] you WILL get ONE CHARACTER.
Your code is horribly horribly complex, anyway.
Why would you send a delimited string from PHP instead of just sending an array, to start with?
And why is your loop so complex?
Why not simply:
Code:
function changefield(unique_id,userid,active,f_name,l_name,contact_n,contact_e,permission_group_name, permission_groups)
{
var groupArray =permission_groups.split("_");
var group = "";
for ( var g = 0; g < groupArray.length; ++g )
{
group += '<option value="' + groupArray[number] + '">' + groupArray[number] + '</option>';
}
...