In case anyone has the same question, here's how I eventually did it: jQuery.fn.loadData = function(){ var rows = $("#curveData tbody tr");
for (var trIdx = 0; trIdx < rows.length; trIdx++) { var inputs = $(rows[trIdx]).find("input"); for (var inpIdx = 0; inpIdx < inputs.length; inpIdx++){ if (trIdx < d1.length) { inputs[inpIdx].value = d1[trIdx][inpIdx]; // bind data } else { inputs[inpIdx].value = ''; // set to blank because there's no data } } } } On Sep 3, 5:05 pm, rolfsf <[EMAIL PROTECTED]> wrote: > I have some data: > > d1 = [[5,10],[10,15],[12,15],[15,18],[20,23]] > > and I have a table with text inputs: > > <table cellpadding="0" cellspacing="0" id="curveData"> > <thead> > <tr> > <th>#</th> > <th>Quantity</th> > <th>Price</th> > </tr> > </thead> > <tbody> > <tr> > <td>1</td> > <td><input type="text" class="qty" > size="8"></input></td> > <td><input type="text" class="price" > size="8"></input></td> > </tr> > <tr> > <td>2</td> > <td><input type="text" class="qty" > size="8"></input></td> > <td><input type="text" class="price" > size="8"></input></td> > </tr> > > ... etc ... > > <tr> > <td>10</td> > <td><input type="text" class="qty" > size="8"></input></td> > <td><input type="text" class="price" > size="8"></input></td> > </tr> > </tbody> > </table> > > How do I load the data into the text inputs (assume I click a > button#loadData)? There may same number of data pairs -or less- as > there are input pairs. > > Thanks!