473,383 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to add dynamic textbox (row) and save to database using PHP

1
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!

Expand|Select|Wrap|Line Numbers
  1. <script type="text/JavaScript"> 
  2. function addRow(r){ 
  3. var root = r.parentNode;//the root 
  4. var allRows = root.getElementsByTagName('tr');//the rows' collection 
  5. var cRow = allRows[0].cloneNode(true)//the clone of the 1st row 
  6. var cInp = cRow.getElementsByTagName('input');//the inputs' collection of the 1st row 
  7. for(var i=0;i<cInp.length;i++){//changes the inputs' names (indexes the names) 
  8. cInp[i].setAttribute('name',cInp[i].getAttribute('name')+'_'+(allRows.length+1)) 
  9. root.appendChild(cRow);
  10. function shownames(){ 
  11. var allInp=document.getElementsByTagName('input'); 
  12. for(var i=0;i<allInp.length;i++){ 
  13. alert(allInp[i].name) 
  14. </script> 
My HTML code:

Expand|Select|Wrap|Line Numbers
  1. <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>
Nov 17 '12 #1
1 4166
Luuk
1,047 Expert 1GB
with your example values will be available as

The first column:
textfield_a; textfield_a_2; textfield_a_3; textfield_a_4; ...

The second column:
textfield_b; textfield_b_2; textfield_b_3; .......

The third column:
textfield_c; textfield_c_2; .....
Nov 17 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Pato Secruza | last post by:
Hi everyone! I have a really frustrating error and need help. I’m trying to do a function that gets the properties and names of the fields in a MS Access database using ASP. I haven’t...
1
by: Kum | last post by:
Hi, I need help in asp.net dynamic textbox controls validation. I am creating textbox controls dynamically on a asp.net webpage. Now after creating the textboxes on the page I want to validate...
2
by: zoneal | last post by:
Anyone can help me how to do dynamic textbox appearance? need it for matrix data entry, suppose i enter 3 and 4 then the 3x4 textboxes will appear.. thank you very much.
2
by: rockdale | last post by:
Hi, All: I have a datagrid that embedded 3 textbox using TemplateColumn. When the user key in value in the first textbox, I need to check to see if this value is between the the values in other...
1
by: shailendra24 | last post by:
i have problem.i inserting row dynamically to html table.validation is working on only first row not the other row.urgent
2
by: Christina | last post by:
Hello !! I am creating a dynamic textbox and want to validate it using the requiredfieldvalidator. These are the steps which I tried: ==================================================== 1)...
5
by: giannis | last post by:
I am a newbie with VB. I'm trying to add a new row to my database using the BindingSource. I use the AddNew() and EndEdit() methonds but my changes dont saved at my database ... What is wrong ?...
1
by: hello2008 | last post by:
Hi, I have just started coding in PHP. I have coded a web page using HTML, JS, and PHP. An HTML table has to be populated dynamically using the data from the backend. Presently I have 5...
9
by: kumarrk | last post by:
Hi all, i am using place holder for dynamic textbox and label box, then when i enter the values in textbox then i click the add button and save to database, but i couldnt get the dynamic textbox...
4
by: marisenthil | last post by:
How to access the value of the dynamic textbox by its id? I created more dynamic textbox using the below in loop Dim tb As New TextBox tb.ID = "txt_" + Str$(i) and it assigned unique...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.