user3631797
user3631797

Reputation: 35

Loop the array and fill value in dynamic textbox in jquery

Here splitValues contains array and .split is a class in multiline texbox which is generated dynamically now i want fill the textbox with this array. I have done this much but not getting further?

function InsertItems(splitValues) {
    $(".split").each(function () {           
        if (splitValues != "") {
            $(this).val(splitValues);//
        }
    });
}

Upvotes: 1

Views: 784

Answers (1)

Jai
Jai

Reputation: 74738

change this:

$(this).val(splitValues);//

to this:

$(this).val(splitValues.join());//

Updates:

$(".split").each(function (i, elem) {           
     $(this).val(splitValues[i]);//
});

Updated Demo as suggested by Milind.

Upvotes: 2

Related Questions