miyotz Posted November 17, 2012 Share Posted November 17, 2012 Hi. I have here my Javascript code that adds dynamic textbox (row) my problem is how can I save this to database using PHP script? How you can help me guys.. Thanks! <script type="text/Javascript"> function addRow®{ var root = r.parentNode;//the root var allRows = root.getElementsByTagName('tr');//the rows' collection var cRow = allRows[0].cloneNode(true)//the clone of the 1st row var cInp = cRow.getElementsByTagName('input');//the inputs' collection of the 1st row for(var i=0;i<cInp.length;i++){//changes the inputs' names (indexes the names) cInp.setAttribute('name',cInp.getAttribute('name')+'_'+(allRows.length+1)) } root.appendChild(cRow); } function shownames(){ var allInp=document.getElementsByTagName('input'); for(var i=0;i<allInp.length;i++){ alert(allInp.name) } } </script> My HTML code: <form method= POST> <table width="1024" border="0" cellspacing="6" cellpadding="0"> <tr> <td width="195"><div class="user"><input type="text" name="textfield_a" id="user" tabindex="6"/></div></td> <td width="410"><div class="reported"><input type="text" name="textfield_b" id="reported" tabindex="7"/></div></td> <td width="399"><div class="reported"><input type="text" name="textfield_c" id="reported" tabindex="8"/></div></td> <td width="10"><input name="button" type="button" value="+" onclick="addRow(this.parentNode.parentNode)"></td> </tr> </table> </form> Link to comment https://forums.phpfreaks.com/topic/270815-how-to-add-dynamic-textbox-row-and-save-to-database-using-php/ Share on other sites More sharing options...
play_ Posted November 21, 2012 Share Posted November 21, 2012 few things. 1. Use code tags to markup code 2. Use jQuery 3. "function addRow®{" what? Link to comment https://forums.phpfreaks.com/topic/270815-how-to-add-dynamic-textbox-row-and-save-to-database-using-php/#findComment-1393939 Share on other sites More sharing options...
rjmcintyre7 Posted November 21, 2012 Share Posted November 21, 2012 Can you possibly repost your code in a more readable format with indents - especially the html? It's near impossible to answer quickly with the current formatting. Link to comment https://forums.phpfreaks.com/topic/270815-how-to-add-dynamic-textbox-row-and-save-to-database-using-php/#findComment-1394173 Share on other sites More sharing options...
mrMarcus Posted November 21, 2012 Share Posted November 21, 2012 few things. 1. Use code tags to markup code 2. Use jQuery 3. "function addRow®{" what? He's obviously registered that function name as a trademark Link to comment https://forums.phpfreaks.com/topic/270815-how-to-add-dynamic-textbox-row-and-save-to-database-using-php/#findComment-1394180 Share on other sites More sharing options...
play_ Posted November 21, 2012 Share Posted November 21, 2012 He's obviously registered that function name as a trademark He's just about ready to sue every software maker that uses a function called addRow Link to comment https://forums.phpfreaks.com/topic/270815-how-to-add-dynamic-textbox-row-and-save-to-database-using-php/#findComment-1394222 Share on other sites More sharing options...
SofWare Posted December 21, 2012 Share Posted December 21, 2012 I haven't read his javascript in detail (so I won't get sued for using his function) but it does look like what he really needs to do is understand ajax to communicate with php and then he needs to understand how to save data to mysql using php - there are two different things he needs to understand. Link to comment https://forums.phpfreaks.com/topic/270815-how-to-add-dynamic-textbox-row-and-save-to-database-using-php/#findComment-1400791 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.