I am creating a table dynamically adding lines to the table as the user completes each line. I would like the cursor to appear in the second cell of the new row after it has been created, but I seem to have some problems with that. At this point I am not even using the variable cNextLine I am just trying to advance to the 2nd cell in the 2nd line. The focus seems to go to the address box of the browser.
Here is an abbreviated version of the code:
Here is an abbreviated version of the code:
Code:
var cNextLine = 1 function addBlankDetailLine() { cNextLine += 1 var tr, td; tbody = document.getElementById('detailLines'); //make new row tr = tbody.insertRow(tbody.rows.length); //make new cell td = tr.insertCell(tr.cells.length); //fill in content td.innerHTML = '<input '+ 'type="text" '+ 'id ="rLine~'+cNextLine+'" '+ 'name="rLine~'+cNextLine+'" '+ 'value="'+cNextLine+'." '+ 'size ="4" '+ 'class="InputText" '+ 'readonly '+ 'tabindex="-1" '+ '/> ' //make new cell td = tr.insertCell(tr.cells.length); td.innerHTML = '<input '+ 'type="text" '+ 'id ="JOBID~'+cNextLine+'" '+ 'name="JOBID~'+cNextLine+'" '+ 'class="InputText" '+ '/> ' //make new cell td = tr.insertCell(tr.cells.length); td.innerHTML = '<input '+ 'type="text" '+ 'id ="TOLLS~'+cNextLine+'" '+ 'name="TOLLS~'+cNextLine+'" '+ 'class="InputText" '+ 'size ="8" '+ 'maxlength="7" '+ 'onblur ="if (createNext(this)) {addBlankDetailLine();}" +' '/>' document.getElementById("JOBID~2").select; document.getElementById("JOBID~2").focus(); }
Comment