Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is that all the input fields use the same id, thus <code>document.getElementById("testname")</code> and <code>document.getElementById("rate")</code> will always return the first input field found in the DOM.</p> <p>You should generate distinguishable ids for the input fields and use those for referencing.</p> <h3>Update with pseudo-code</h3> <p>You could do that by changing your html code to</p> <pre><code>&lt;td&gt;&lt;INPUT type="text" id="tc1" name="testcode" style="width:86px;border:1px solid gray" onblur="mango1(this.value, 1)"/&gt;&lt;/TD&gt; &lt;TD&gt;&lt;INPUT type="text" id="testname1" name="testname" style="width:165px;border:1px solid gray"/&gt;&lt;/TD&gt; &lt;TD&gt;&lt;INPUT type="text" id="rate1" name="rate" style="width:65px;border:1px solid gray" onclick="addRow('dataTable')" /&gt;&lt;/TD&gt; </code></pre> <p>In your JS code, instead of</p> <pre><code>newcell.innerHTML = table.rows[0].cells[i].innerHTML; </code></pre> <p>You need to manipulate the ID like e.g.</p> <pre><code>newcell.innerHTML = increaseTheNumberOfTheIdAndTheRowPassedToMango(table.rows[0].cells[i].innerHTML); </code></pre> <p>with <code>increaseTheNumberOfTheIdAndTheRowPassedToMango</code> being a function you need to write yourself; e.g. using regular expressions or creating the HTML manually or <em>you name it</em>.<br/> Then you need to adapt the <code>mango</code> function to</p> <pre><code>function mango1(testcode, row) { ... document.getElementById("testname" + row).value=item[0]; document.getElementById("rate" + row).value=item[1]; ... } </code></pre> <p>This is an illustration of one of many solutions to get you started.</p>
    singulars
    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.
    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