为何用sql语句插入记录,一次总是有二条一样的记录呢?

为何我在用javascript中的sql语句执行对数据库插入记录的操作时,明明只选择了一个记录,执行了一次循环,但是却插入了二条一样的记录呢?(如果我选择了二条记录,就会执行四次插入)请大神帮我检查一下,看javascript语句有没有错误。
语句如下,是一个按钮的点击事件的语句(红字部分就是插入的语句):

var location = this.options.location;  //获取当前控件的位置
var cr = FR.cellStr2ColumnRow(location);
var col = cr.col;  //列号
var ro = cr.row;  //行号

var products = [];  
var ordernums = [];  
var ordernums1 = [];
var ordernums2 = [];
var $span = $('.fr-checkbox-checkon');  
var $tds = $("td").has($span);     
var $trs = $("tr").has($tds);  
for(var i=1; i<$trs.length;i++){  
var row = $("td:eq(0)",$($trs)).attr("row");   
products.push(contentPane.getCellValue(2,row));
contentPane.curLGP.setCellValue(1, ro+1+i,contentPane.getCellValue(2,row) );

ordernums.push(contentPane.getCellValue(6,row));
contentPane.curLGP.setCellValue(5, ro+1+i,contentPane.getCellValue(6,row) );

ordernums1.push(contentPane.getCellValue(7,row));
contentPane.curLGP.setCellValue(6, ro+1+i,contentPane.getCellValue(7,row) );

ordernums2.push(contentPane.getCellValue(8,row));
contentPane.curLGP.setCellValue(7, ro+1+i,contentPane.getCellValue(8,row) );

var t1 = contentPane.getCellValue(2,row);
var t2 = contentPane.getCellValue(6,row);
var t3 = contentPane.getCellValue(7,row);
var t4 = contentPane.getCellValue(8,row);
alert(t1+t2+t3+t4);

var p1= "'"+t1+"'"   ;
var p2= "'"+t2+"'"   ;
var p3= "'"+t3+"'"   ;
var p4= "'"+t4+"'"   ;
var sql2="insert into FGF进货表 ( DATE,category,product_id,product,SPECIFICATION,quantity,price) select date,category,product_id,product,specification,quantity,price from  RM库存表 where specification="+ p2 + "and quantity="+ p3 + "and date="+ p1 + "and price="+ p4;

var k2='sql("RM",'+'"' + sql2 + '",1,1)';
alert(k2);
var b2=FR.remoteEvaluate(k2);


FineReportzzghty 发布于 2017-6-30 03:49
悬赏:2 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共4回答
最佳回答
0
macro_hard发布于2017-6-30 03:49(编辑于 2023-9-6 09:34)
555
最佳回答
0
monvzhilei发布于2017-6-30 07:31(编辑于 2023-9-6 09:34)
555
最佳回答
0
Poseidon发布于2017-6-30 09:07(编辑于 2023-9-6 09:34)
555
最佳回答
0
zzghty发布于2017-6-30 17:59(编辑于 2023-9-6 09:34)
555
  • 0关注人数
  • 401浏览人数
  • 最后回答于:2017-6-30 17:59
    活动推荐 更多
    热门课程 更多
    返回顶部