• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Insert more than one row in database.

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi List[],

I have created a jsp page and used java script.I am dyanmic adding row in table from text box.Its showing the data in the row which i have entered in the textbox.But now i want to know how to insert these row in database.Please help me how to do this.

Thanks
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pankaj semwal:
But now i want to know how to insert these row in database.



please can you post that so far what you tried?
 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Below is my code which adding row dynamically on clicking button.I want to insert these data in database.Any idea how to do this kind of work.



function addrows(cid)

//here we point the tbody variable to the table
var tbody = document.getElementById(cid).getElementsByTagName("TBODY")[0];

//here we create a row element
var row = document.createElement("TR");

//here we create the first cell element
var t1 = document.createElement("TD");

//here we popuate the first cell with 'Test1'
t1.innerHTML=document.getElementById("t1").value;

//here we create the second cell element
var t2 = document.createElement("TD");

//here we popuate the first cell with email@server.com'
t2.innerHTML=document.getElementById("t2").value;

var t3 = document.createElement("TD");

t3.innerHTML=document.getElementById("t3").value;
//here we append the cells to the created row element
row.appendChild(t1)
row.appendChild(t2)
row.appendChild(t3);
document.getElementById("t1").value="";
document.getElementById("t2").value="";
document.getElementById("t3").value="";
//here we append the created row element to the table
tbody.appendChild(row)
 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pankaj semwal:
Hi,

Below is my code which adding row dynamically on clicking button.I want to insert these data in database.Any idea how to do this kind of work.



function addrows(cid)

//here we point the tbody variable to the table
var tbody = document.getElementById(cid).getElementsByTagName("TBODY")[0];

//here we create a row element
var row = document.createElement("TR");

//here we create the first cell element
var t1 = document.createElement("TD");

//here we popuate the first cell with 'Test1'
t1.innerHTML=document.getElementById("t1").value;

//here we create the second cell element
var t2 = document.createElement("TD");

//here we popuate the first cell with email@server.com'
t2.innerHTML=document.getElementById("t2").value;

var t3 = document.createElement("TD");

t3.innerHTML=document.getElementById("t3").value;
//here we append the cells to the created row element
row.appendChild(t1)
row.appendChild(t2)
row.appendChild(t3);
document.getElementById("t1").value="";
document.getElementById("t2").value="";
document.getElementById("t3").value="";
//here we append the created row element to the table
tbody.appendChild(row)



Hi Pankaj,
it must be calling addrows method everytime you add a new row. In the end of this function, you can call a method that will insert the three values in the database. It can be done with the help of AJAX.

Cheers,
[ December 03, 2008: Message edited by: Patricia Samuel ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic