Trying to assign Javascript array variable to HTML input value attribute
===

I have something of a complicated question to ask, and my Google-Fu is apparently too weak to solve this so far.

I'm building a form of sorts that's supposed to flip through a bunch of names in an array, present them all for selection, and:

 - Put the selected name into one set of form inputs (text, specifically);
 - Dynamically generate a bunch of divs with more of the same text inputs;
 - Put the *rest* of the names into those new divs

I've gotten the first two of these to work just fine, with a mix of JQuery and regular Javascript. But the problem I have occurs at the last step, there.

Here's a sample line for what I'm doing:

    var lname = '<p>Last name: <input type=\'text\' class=\'inputbox\' value=lastNames[i]></p>';
    ...
    ...
    $('.others').append(...,lname,...);

This is inside a `for (i=0; i<lastNames.length; i++)` loop, so the plan is to create a div and the inputs inside for each name in the array. This already works. The problem is that when I load the page and select a name, 3 new divs show up...and the text inside each box is, for example, lastNames[i] instead of Smith.

What am I missing syntactically here? Or is it more complex than I was thinking?