Note that there are some explanatory texts on larger screens.

plurals
  1. POrows added via javascript to table inside form don't submit
    primarykey
    data
    text
    <p>Hy, I have read many discussion on this argument but I just can't find a solution. I have table inside a form, the first rows of this table are displayed by a php script, I won't the user to be able to add a row to the table so that he can insert a new set of values. the problem is that this new rows that I insert don't get submitted. here is the php code</p> <pre><code> &lt;form method="post"&gt; &lt;table name="elencoAltriContatti" id="elencoAltriContatti"&gt; &lt;button type="button" class="btn primary success" onClick="showNewContatti();" name="nuovo"&gt;NUOVO&lt;/button&gt; &lt;tr&gt; &lt;td&gt;&lt;p&gt;&lt;strong&gt;Nome&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p&gt;&lt;strong&gt;Qualifica&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p&gt;&lt;strong&gt;Email&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;p&gt;&lt;strong&gt;Telefono&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php echo "&lt;tr&gt;"; echo "&lt;td&gt;&lt;p&gt;&lt;input type=\"text\" id=\"nome\" name=\"NOME[]\" value=\"".$row['NOME']."\" class=\"input-text3\" onchange=\"selectCheckbox('".$i."')\"&gt;&lt;/p&gt;&lt;/td&gt;"; echo "&lt;td&gt;&lt;p&gt;&lt;input type=\"text\" id=\"qualifica\" name=\"QUALIFICA[]\" value=\"".$row['QUALIFICA']."\" class=\"input-text3\" onchange=\"selectCheckbox('".$i."')\"&gt;&lt;/p&gt;&lt;/td&gt;"; echo "&lt;td&gt;&lt;p&gt;&lt;input type=\"text\" id=\"email\" name=\"EMAIL[]\" value=\"".$row['EMAIL']."\" class=\"input-text3\" onchange=\"selectCheckbox('".$i."')\"&gt; &lt;/p&gt;&lt;/td&gt;"; echo "&lt;td&gt;&lt;p&gt;&lt;input type=\"text\" id=\"telefono\" name=\"TELEFONO[]\" value=\"".$row['TELEFONO']."\" class=\"input-text3\" onchange=\"selectCheckbox('".$i."')\"&gt;&lt;/p&gt;&lt;/td&gt;"; echo "&lt;td&gt;&lt;input id=\"".$i."\" name=\"CHECKBOX[]\" type=\"checkbox\" value=\"\" style=\"float:right\"&gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; ?&gt; &lt;/table&gt; &lt;div class="control-group"&gt; &lt;div class="controls"&gt; &lt;button type="reset" name="reset" class="btn info"&gt;CANCELLA&lt;/button&gt; &lt;button type="submit" name="submit" class="btn info" &gt;SALVA&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>wich works just fine, and here is the javascript function I use </p> <pre><code>function showNewContatti(){ var table = document.getElementById('elencoAltriContatti'); var lastRow = table.rows.length; var row=table.insertRow(lastRow); var nome=row.insertCell(0); var qualifica=row.insertCell(1); var email=row.insertCell(2); var telefono=row.insertCell(3); var checkbox=row.insertCell(4); nome.innerHTML="&lt;p&gt;&lt;input type=\"text\" id=\"nome\" name=\"NOME[]\" class=\"input-text3\" onchange=\"selectCheckbox('"+lastRow+"')\"&gt;&lt;/p&gt;"; qualifica.innerHTML="&lt;p&gt;&lt;input type=\"text\" id=\"qualifica\" name=\"QUALIFICA[]\" class=\"input-text3\" onchange=\"selectCheckbox("+lastRow+")\"&gt;&lt;/p&gt;"; email.innerHTML="&lt;p&gt;&lt;input type=\"text\" id=\"email\" name=\"EMAIL[]\" class=\"input-text3\" onchange=\"selectCheckbox("+lastRow+")\"&gt;&lt;/p&gt;"; telefono.innerHTML="&lt;p&gt;&lt;input type=\"text\" id=\"telefono\" name=\"TELEFONO[]\" class=\"input-text3\" onchange=\"selectCheckbox("+lastRow+")\"&gt;&lt;/p&gt;"; checkbox.innerHTML="&lt;input type=\"checkbox\" id=\""+lastRow+"\" name=\"CHECKBOX[]\" style=\"float:right\"&gt;";} </code></pre> <p>new rows added with this function just don't get submitted, do you have some ideas? thank's for the help</p> <p>EDIT: I have changed my javascript function, now it looks like this:</p> <pre><code> var table = document.getElementById('elencoAltriContatti'); var lastRow = table.rows.length; var Iterator=lastRow; var row=table.insertRow(lastRow); var nome = row.insertCell(0); var cell = document.createElement('input'); cell.type = 'text'; cell.name = 'nome' + Iterator; cell.id = 'nome' + Iterator; cell.className= 'input-text3'; cell.onchange= function(){ selectCheckbox(Iterator); }; nome.appendChild(cell); </code></pre> <p>but I still have the same problem, what else can I do? </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