This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSP and the fly likes Insert  more than one row in database. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Insert  more than one row in database." Watch "Insert  more than one row in database." New topic
Author

Insert more than one row in database.

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
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
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Oct 07, 2008
Posts: 300
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)
Patricia Samuel
Ranch Hand

Joined: Sep 12, 2007
Posts: 300
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Insert more than one row in database.
 
Similar Threads
ORA-01460: unimplemented or unreasonable conversion requested
Inserting Files to Database.
how to insert row in POI hssf
sql question
Please help with the 3 Hardest Javascript problems in the world