本文介绍了将数据从jsp表单插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





首先感谢您的回复我将在下面提供详细信息,请查看和建议



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 ;
}
}
}
解决方案

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;
         }
             }
             }
解决方案


这篇关于将数据从jsp表单插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 23:18
查看更多