Connecting Tech Pros Worldwide Forums | Help | Site Map

save dynamicaly created table to the database....

Member
 
Join Date: Mar 2009
Location: India
Posts: 52
#1: Jul 8 '09
hi
i am using this code for adding /deleting rows dynamically :

Expand|Select|Wrap|Line Numbers
  1. function addRow()
  2. {
  3.   var tbl = document.getElementById('applications');
  4.   var lastRow = tbl.rows.length;
  5.   // if there's no header row in the table, then iteration = lastRow + 1
  6.   var iteration = lastRow;
  7.   var row = tbl.insertRow(lastRow);
  8.  
  9.  
  10.   // right cell
  11.   var cellRight = row.insertCell(0);
  12.   var el = document.createElement('input');
  13.  
  14.   el.type = 'text';
  15.   el.name = 'application_field1' + iteration;
  16.   el.id = 'application_field1' + iteration;
  17.   el.size = 45;
  18.   el.className='cellData';
  19.   el.style.width='220px'
  20.   el.style.height='17px'
  21.   el.title='Enter Application Name'
  22.   //el.onkeypress = keyPressTest;
  23.   cellRight.appendChild(el);
  24.  
  25.  
  26.  
  27.   var cellMiddle = row.insertCell(1);
  28.   var fl = document.createElement('input');
  29.  
  30.   fl.type = 'text';
  31.   fl.name = 'application_field2' + iteration;
  32.   fl.id = 'application_field2' + iteration;
  33.   fl.size = 45;
  34.   fl.className='cellData';
  35.   fl.style.width='220px'
  36.   fl.style.height='17px'
  37.   fl.title='Enter Application Ticket Number'
  38.   //el.onkeypress = keyPressTest;
  39.   cellMiddle.appendChild(fl);
  40.  
  41.  
  42.   var cellLeft = row.insertCell(2);
  43.   var gl = document.createElement('input');
  44.  
  45.   gl.type = 'text';
  46.   gl.name = 'application_field3' + iteration;
  47.   gl.id = 'application_field3' + iteration;
  48.   gl.size = 45;
  49.   gl.className='cellData';
  50.   gl.style.width='220px'
  51.   gl.style.height='17px'
  52.   gl.value='mm/dd/yyyy'
  53.   gl.onfocus= function() {gl.value=""};
  54.   gl.title='Enter Application Ticket Number'
  55.   //el.onkeypress = keyPressTest;
  56.   cellLeft.appendChild(gl);
  57.  
  58.   }
  59.  
  60.   function removeRow()
  61. {
  62.   var tbl = document.getElementById('applications');
  63.   var lastRow = tbl.rows.length;
  64.   if (lastRow > 3) tbl.deleteRow(lastRow - 1);
  65. }
  66.  
  67.  
  68.  

how can i save these to the database ??

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,664
#2: Jul 8 '09

re: save dynamicaly created table to the database....


Quote:

Originally Posted by aashishn86 View Post

how can i save these to the database ??

in general, create a form, insert the data to save, submit the form*, use a server script to save the submitted data to the DB.

* - can also be done via AJAX
Member
 
Join Date: Mar 2009
Location: India
Posts: 52
#3: Jul 8 '09

re: save dynamicaly created table to the database....


i create the form...
and submit the page to another page...
now how do i access this data on the other page ???
Member
 
Join Date: Mar 2009
Location: India
Posts: 52
#4: Jul 8 '09

re: save dynamicaly created table to the database....


hi
i have been able to retreive the valeues in the next form using
request.form

what do i do next to save them in sql
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#5: Jul 8 '09

re: save dynamicaly created table to the database....


That's not a JavaScript question. Ask in the forum relevant to your server-side language.
Member
 
Join Date: Mar 2009
Location: India
Posts: 52
#6: Jul 8 '09

re: save dynamicaly created table to the database....


sorry..
can you move it to the asp forum please...
Reply