将数据从jsp表单插入数据库 [英] inserting data from jsp form into database
问题描述
首先感谢您的回复我将在下面提供详细信息,请查看和建议
i我试图使用下面的代码添加动态行(html,使用javascript)(为此我在html中创建了一行具有相同的字段,一旦用户点击添加按钮我正在调用此函数)它工作,我是能够动态创建行并且还能够将数据插入数据库(仅使用IE)(使用JSP)但是使用任何其他浏览器我能够动态添加行(在mozilla,chrome中)但是当我保存数据时它是仅获取第一条记录,而不是剩余的值
function addRow(tableID){
var table = document .getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows [ 0 ]。cells.length;
for ( var i = 0 ; i< colCount; i ++){
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows [ 0 ]。cells [i] .innerHTML;
switch (newcell.childNodes [ 0 ]。type){
case select-one
newcell.childNodes [ 0 ]。selectedIndex = 0 ;
break ;
case text
newcell.childNodes [ 0 ]。value =
break ;
case select-one
newcell.childNodes [ 0 ]。selectedIndex = 0 ;
break ;
case select-one
{
newcell.childNodes [ 0 ]。selectedIndex = 0 ;
}
break ;
case text :
newcell.childNodes [ 0 ]。value =
break ;
}
}
}
请参考:
动态添加和删除HTML表格中的行 [ ^ ]
使用JavaScript动态添加/删除HTML表格中的行 [ ^ ]
在这里,您将获得一些代码,以便使用动态添加和删除HTML表格中的行JavaScript
。
如何通过JSP表单将数据插入数据库 [ ^ ]
hi,
firstly thank you for the reply i am giving the details below kindly check and advice
i am trying to add dynamic rows(html,using javascript) using the below code(for this in html i have created one row with the same fields and once user clicks add button i am calling this function) it works and i am able to create rows dynamically and also able to insert the data into the database(using IE only)(using JSP) but with any other browser i am able to add rows dynamically(in mozilla,chrome) but when i am saving data it is taking the first record only and not the remaining values
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for(var i=0; i<colCount; i++) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[0].cells[i].innerHTML;
switch(newcell.childNodes[0].type) {
case "select-one"
newcell.childNodes[0].selectedIndex = 0;
break;
case "text"
newcell.childNodes[0].value = ""
break;
case "select-one"
newcell.childNodes[0].selectedIndex = 0;
break;
case "select-one"
{
newcell.childNodes[0].selectedIndex = 0;
}
break;
case "text":
newcell.childNodes[0].value = ""
break;
}
}
}
Please refer:
Dynamically add and remove rows in an HTML table[^]
Dynamically Add/Remove rows in HTML table using JavaScript[^]
Here you will get some code for reference to dynamically add and remove rows in an HTML table usingJavaScript
.
How to insert data into databse by JSP form[^]
这篇关于将数据从jsp表单插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!