473,394 Members | 1,737 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,394 software developers and data experts.

How to collect values(data) of dynamically added rows (HTML table)? Using php / XAMPP

i created a simple form with dynamic table , this table rows increments by the user input values , so i want to collect this table columns data whatever it's rows number and ALSO i need to increment the combo box or the select(option) every time a new row created so it should be like default combo box values .

Here is the code:

Expand|Select|Wrap|Line Numbers
  1.     <html>
  2.     <head>
  3.         <script language="javascript">
  4.  
  5.             function AddRows()
  6.             {
  7.              //find the table element
  8.               var tableelement=document.getElementById("mytable")
  9.  
  10.               //find the value in no of rows control
  11.               var rows=document.getElementById("noofrows").value;
  12.  
  13.               //find the existing no of rows in the table
  14.               var tablerowcount=tableelement.rows.length;
  15.               var currowcount=tablerowcount;
  16.  
  17.               for(i=1;i < rows;i++ ) {
  18.                 //insert a row as the last row of the table
  19.  
  20.                 var row=tableelement.insertRow(currowcount);
  21.                 //insert a first cell/td in the newly added row
  22.                 var cellid=row.insertCell(0);
  23.                 cellid.innerHTML="<b>" + currowcount +"</b>";
  24.                 //insert a second cell/td in the newly added row
  25.                 var cellid2=row.insertCell(1);
  26.  
  27.                 cellid2.innerHTML="<input value='' id='" + currowcount +"_name' /> ";
  28.                 var cellid3=row.insertCell(1);
  29.                 cellid3.innerHTML="<input value='' id='" + currowcount +"_name' /> ";
  30.                 var cellid4=row.insertCell(1);
  31.                 cellid4.innerHTML="<input value='' id='" + currowcount +"_name' /> ";
  32.                 var cellid5=row.insertCell(1);
  33.                 cellid5.innerHTML="<input value='' id='" +currowcount +"_name' /> ";
  34.                 var cellid6=row.insertCell(1);
  35.                 cellid6.innerHTML="<input value='' id='" +currowcount+"_name' /> ";
  36.  
  37.  
  38.                 //increment the table row count variable
  39.                 var currowcountcurrowcount=currowcount++;
  40.  
  41.               }
  42.            }
  43.           </script>
  44.    </head>
  45.     <body>
  46.     <form method="post" action="insert.php>
  47.  
  48.     Carton Number :<input type="text" name="cn"> <br>
  49.     Business Unit :<input type="text" name="bu"> <br>
  50.     No of Files  :<input type="noofrows" id="noofrows"  value="1" name="nof" />
  51.  
  52.      <input name="add" id="add" type="button" value="Add" onClick="AddRows()"/>
  53.  
  54.         <table name="mytable" id="mytable" border=1>
  55.             <tr>
  56.                 <td>
  57.                     <b>SN</b>
  58.                 </td>
  59.                 <td>
  60.                     <b>From</b>
  61.                 </td>
  62.                 <td>
  63.                     <b>To</b>
  64.                 </td>
  65.                 <td>
  66.                      <b>Range</b>
  67.                 </td>
  68.                 <td>
  69.                       <b>Document Category</b>
  70.                 </td>
  71.                 <td>
  72.                       <b>Document Type</b>
  73.                 </td>
  74.             </tr>
  75.             <tr>
  76.                 <td>
  77.                     <b>1</b>
  78.                 </td>
  79.                 <td>
  80.                     <input value="" id='1_name' >
  81.                 </b>
  82.             </td>
  83.             <td>
  84.                                 <input value="" id='1_name'/>
  85.                             </b>
  86.             </td>
  87.             <td>
  88.                                             <input value="" id='1_name' />
  89.                                         </b>
  90.             </td>
  91.  
  92.             <td>
  93.             <Select id='select' />
  94.  
  95.  
  96.                                               <option name="option" value="finance">Finance Documents</option>
  97.                                               <option name="option" value="hr">HR Documents</option>
  98.                                               <option name="option" value="test">test</option
  99.             </Select>
  100.                                         </b>
  101.             </td>
  102.             <td>
  103.  
  104.             <Select id='select' />
  105.  
  106.  
  107.                                   <option name="option" value="CP">Cash movement</option>
  108.                                   <option name="option" value="PV">Payment Voucher</option>
  109.                                   <option name="option" value="RV">RV</option
  110.             </Select>
  111.                                                     </b>
  112.             </td>
  113.  
  114.         </tr>
  115.     </table>
  116.     <br/>
  117.     <input type="submit"name="submit"value="Submit"/>
  118.  
  119. </form>
  120. </body>
  121. </html>
Mar 12 '13 #1
1 10713
acoder
16,027 Expert Mod 8TB
Where are you trying to "collect" the data? Do you want to get these values in the JavaScript code. Show your attempt at this part of your code.
Mar 13 '13 #2

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

Similar topics

3
by: Sandros | last post by:
Background: I'm collecting usability statistics for a group of applications. Each count has the following attributes: date, application, major heading, minor heading, count. My intent is to pull...
1
by: Raghuram Banda | last post by:
Hi all, I've created a table with Table Header and the table may or may not contain any rows initially. I've included a .css file in <head> section of my HTML script and I'm creating rows to...
10
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim...
2
by: lisha | last post by:
I have code which generates html table on the fly and fills it up with data. i have to add a print button so that i am able to print the output in html table to the printer. Also, is it possible to...
2
by: Geary | last post by:
I am trying to programmatically add rows of data to a table web control in VS2005. I am getting the data from 2 drop-down controls and 2 text-boxes. The code below is executed when I click on the...
18
by: sandeepdesai | last post by:
Hi.. i am new to javascripts, i am using a addRow scipt to add rows to a table dynamically. one of the cells(say cell2) in a Nth row needs to be hyperlinked to another script. for example: ...
4
by: ochocki | last post by:
Hi, On site I create there is a lot of tables. Those tables are of course generated using Table class, which generates html tables using <table>/ <trand <tdtags. It is very trendy and recomended...
2
by: mahalakshmiDevi | last post by:
I am automating the testing of an web application. The application consist of HTML table with the list of items. I wanted to click on particular item of the table. I have provided the source code of...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.