特卖上下左右最终版

  数组 inputField 已经封装了所有的text和checkbox的关键字;所以不用再去写一个数组来存放关键字,这样一劳永逸的解决了问题
  function getFieldArryNum(fieldNm,type,obj){
  var returnObj = new Object();
  var next = null;
  var id = "";
  var row = obj.parentNode.parentNode.parentNode.rowIndex;
  for(var i=0;i<inputField.length;i++){
  if(fieldNm == inputField[i]){
  returnObj.number = i;
  if(type == "1"){
  if(i == 0){
  returnObj.nextFieldNm = inputField[(inputField.length)-1];
  id = pduList[row-2].pduID;
  }else{
  returnObj.nextFieldNm = inputField[i -1];
  id = pduList[row-1].pduID;
  }
  next= document.getElementById(returnObj.nextFieldNm + "_" + id);
  if(!next.disabled){
  next.focus();
  break;
  }else{
  var nextIndex = returnObj.number - 2;
  while (nextIndex--){
  if(!document.getElementById(inputField[nextIndex] + "_" + id).disabled){
  document.getElementById(inputField[nextIndex] + "_" + id).focus();
  break;
  }
  }
  }
  }else if(type == "2"){
  if(i == inputField.length -1){
  returnObj.nextFieldNm = inputField[0];
  id = pduList[row].pduID;
  }else{
  returnObj.nextFieldNm = inputField[i + 1];
  id = pduList[row-1].pduID;
  }
  next= document.getElementById(returnObj.nextFieldNm + "_" + id);
  if(!next.disabled){
  next.focus();
  break;
  }else{
  var nextIndex = returnObj.number+1;
  // alert(nextIndex);
  while (nextIndex++){
  if(!document.getElementById(inputField[nextIndex] + "_" + id).disabled){
  document.getElementById(inputField[nextIndex] + "_" + id).focus();
  break;
  }
  }
  }
  }else{
  returnObj.nextFieldNm = fieldNm;
  }
  }
  }
  //alert(returnObj);
  }
  function okd(obj,fieldNm){
  var code_value =event.keyCode;
  //var arr=new Array("MEMBER_PRICE","PRODUCT_UNIT","DESCRIPTION_2 0");
  var arr = inputField;
  var row = obj.parentNode.parentNode.parentNode.rowIndex;
  var cellIndex = obj.parentNode.parentNode.cellIndex;
  //左移
  if(code_value==37){
  if(!(row==1&&fieldNm==arr[0])){
  getFieldArryNum(fieldNm,1,obj);
  }
  }
  //右移
  if(code_value==39){
  if(!((row==obj.parentNode.parentNode.parentNode.pa rentNode.rows.length-1)&&fieldNm==arr[arr.length-1] )){
  getFieldArryNum(fieldNm,2,obj);
  }
  }
  //上移
  if(code_value==38){
  // 当前行号
  if(row != 1){
  var row2 = obj.parentNode.parentNode.parentNode.rowIndex-2;
  // get id
  var id = pduList[row2].pduID;
  document.getElementById(fieldNm + "_" + id).focus();
  }
  }
  //下移
  if(code_value==40){
  // 当前行号
  if(row != obj.parentNode.parentNode.parentNode.parentNode.ro ws.length-1){
  var row2 = row-1+1;
  // get id
  var id = pduList[row2].pduID;
  document.getElementById(fieldNm + "_" + id).focus();
  }
  }
  }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值