Note that there are some explanatory texts on larger screens.

plurals
  1. POadding focus on a runtime generated input box using javascript
    primarykey
    data
    text
    <p>hi i have a form which dynamically generates a table row on a button click using javascript everything is working fine but now i want to add focus on a newly generated input box in my table row so can anyone help in this? here is my script</p> <pre><code> &lt;script language="javascript" type="text/javascript"&gt; var jj=1; function addRow() { //alert(jj) var tbl = document.getElementById('zimtable'); var lastRow = tbl.rows.length; var iteration = lastRow - 1; var row = tbl.insertRow(lastRow); var firstCell = row.insertCell(0); var el = document.createElement('input'); el.type = 'text'; el.name = 'zimname_' + jj; el.id = 'zimname_' + jj; el.size = 40; el.maxlength = 40; firstCell.appendChild(el); var secondCell = row.insertCell(1); var el2 = document.createElement('input'); el2.type = 'text'; el2.name = 'zimmob_' + jj; el2.id = 'zimmob_' + jj; el2.size = 10; el2.maxlength = 10; secondCell.appendChild(el2); var thirdCell = row.insertCell(2); var element4 = document.createElement("select"); element4.name ='zim_'+jj; var option1 = document.createElement("option"); option1.value='TRUSTY'; option1.innerHTML='TRUSTY'; element4.appendChild(option1); var option2 = document.createElement("option"); option2.value='MUQAMI HAZRAT'; option2.innerHTML='MUQAMI HAZRAT'; element4.appendChild(option2); var option3 = document.createElement("option"); option3.value='MASJIDWAR JAMAAT KA SAATHI'; option3.innerHTML='MASJIDWAR JAMAAT KA SAATHI'; element4.appendChild(option3); thirdCell.appendChild(element4); var fourthCell = row.insertCell(3); var el3 = document.createElement('input'); el3.type = 'text'; el3.name = 'zemail_' + jj; el3.id = 'zemail_' + jj; el3.size = 40; el3.maxlength = 40; fourthCell.appendChild(el3); firstCell.focus(); // alert(i); jj++; makhtab.hh.value=jj; // alert(jj); } &lt;/script&gt; </code></pre> <p>i want to add focus on my first input box in my generated table row</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload