• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 519
  • Last Modified:

disable all the fields in dynamic rows and the inner subrows

this is code for creating dynamic rows and the inner subrows using DOM in javascript;i want to disable all the fields in the dynamic rows;





<html>
<head>
<title> Dynamic Table </title>
<link rel="stylesheet" href="eagle.css">
</head>
<SCRIPT LANGUAGE="JavaScript">
var idCounter = 1;
var counter = 1;
var subIdCounter = 1;
var subCounter = 1;

var shipmentId            =      new Array();
//var shipmentTypes      =      new Array();
var shipmentNo            =      new Array();
var totPieces            =      new Array();
var shipmentWt      = new Array();
var shipmentVol      = new Array();
//Modified by Prathap.T for the issue Vision Deployement-11071
//Modified by B S Reddy on 01 Sep 2004 based on Babu reddy Mail on 01 Sep 2004
var containerTypeValues   = new Array('Standard','High Cube','Flat Rack','Reefer','Reefer High Cube','Open Top','Hard Top','Platform','Insulated','Collapsible Flat Rack','Ventilated','Tank Container','Shipper Owned','Non Operating Reefer');
var containerType = new Array('STD','HC','FR','RE','RHC','OT','HT','PL','IN','CFR','VE','TC','SO','NOR');


var containerSizeValues  = new Array('20-FT','40-FT','45-FT','48-FT');
var containerSize = new Array('20','40','45','48');      

var UOWValues   = new Array('KG');
var UOW = new Array('KG');

var UOVValues  = new Array('CBM');
var UOV = new Array('CBM');      
             shipmentId[0]  = '70104438'
             shipmentNo[0]  = '70104438'
             totPieces[0]    = 35;
             shipmentWt[0]    = 35.0;
             shipmentVol[0]    = 35.0;
             shipmentId[1]  = '70104440'
             shipmentNo[1]  = '70104440'
             totPieces[1]    = 103;
             shipmentWt[1]    = 103.0;
             shipmentVol[1]    = 103.0;


function createRow()
{
      var tab            = document.getElementById("sasDyn");
      var tbody      = document.createElement("tbody");
      tbody.setAttribute("id","tbody"+idCounter)
      var tr            = document.createElement("tr");
      tr.className="formdata";

      var td            = document.createElement("td");
      
      if(idCounter==1)
            td.appendChild(document.createTextNode(' '));
      else
            td.appendChild(addInputElement(idCounter,"","button","delbut","delbut","","<<","deleteRow();","","input"));

      tr.appendChild(td);
      td            = document.createElement("td");
      td.appendChild(document.createTextNode(' '+counter+''));
      tr.appendChild(td);
      td            = document.createElement("td");
      td.appendChild(addSelectElement(idCounter,"containerSize","containerSize",containerSizeValues,containerSize,"select"));
      td.appendChild(addInputElement(idCounter,"","hidden","parent","parent","",idCounter,"","",""));
      td.setAttribute("align","center");
      tr.appendChild(td);
      td            = document.createElement("td");
      td.appendChild(addSelectElement(idCounter,"containerType","containerType",containerTypeValues,containerType,"select"));
      td.setAttribute("align","center");
      tr.appendChild(td);
      td            = document.createElement("td");
      td.appendChild(addInputElement(idCounter,"4","text","containerPrefix","containerPrefix","5","","","s","input"));
      td.setAttribute("align","center");
      tr.appendChild(td);
      td            = document.createElement("td");
      td.appendChild(addInputElement(idCounter,"7","text","containerNumber","containerNumber","5","","","s","input"));
      td.setAttribute("align","center");
      tr.appendChild(td);
      td            = document.createElement("td");
      td.appendChild(addInputElement(idCounter,"9","text","containerPieces","containerPieces","5","","","s","input"));
      td.setAttribute("align","center");
      tr.appendChild(td);
      td            = document.createElement("td");
      td.appendChild(addInputElement(idCounter,"15","text","weight","weight","5","","","s","input"));
      td.appendChild(addSelectElement(idCounter,"UOW","UOW",UOWValues,UOW,"select"));
      td.setAttribute("align","center");
      tr.appendChild(td);

      td            = document.createElement("td");
      td.appendChild(addInputElement(idCounter,"15","text","volume","volume","5","","","s","input"));
      td.appendChild(addSelectElement(idCounter,"UOV","UOV",UOVValues,UOV,"select"));
      td.setAttribute("align","center");
      tr.appendChild(td);

      td            = document.createElement("td");
      td.appendChild(addInputElement(idCounter,"15","text","sealNo1","sealNo1","5","","","s","input"));
      td.setAttribute("align","center");
      tr.appendChild(td);
      td            = document.createElement("td");
      td.appendChild(addInputElement(idCounter,"15","text","sealNo2","sealNo2","5","","","s","input"));
      td.setAttribute("align","center");
      tr.appendChild(td);
      td            = document.createElement("td");
      td.appendChild(addInputElement(idCounter,"15","text","sealNo3","sealNo3","5","","","s","input"));
      td.setAttribute("align","center");
      tr.appendChild(td);

      td            = document.createElement("td");
      td.appendChild(addInputElement(idCounter,"15","hidden","FCRNo","FCRNo","5","","","s","input"));
      td.setAttribute("align","center");
      tr.appendChild(td);


      td            = document.createElement("td");
            td.appendChild(addInputElement(idCounter,"","button","addbut","addbut","",">>","createRow();","","input"));
      tr.appendChild(td);
      tbody.appendChild(tr);
      tr            = document.createElement("tr");
      td            = document.createElement("td");
      td.setAttribute("colSpan","6");
      td.className = "formdata";
      tr.appendChild(td);
      td            = document.createElement("td");
      td.setAttribute("colSpan","7");
      td.className = "formdata";
      var childTab = document.createElement("table");
      childTab.setAttribute("id","sasDynChild"+idCounter);
      childTab.setAttribute("tableCounter","1");
      childTab.setAttribute("cellspacing","1");
      childTab.setAttribute("cellpadding","2");
//      childTab.setAttribute("width","100%");
      td.appendChild(childTab);
      //new code
      var      tbody1      = document.createElement("tbody");
      var      tr1            = document.createElement("tr");
      var td1            = document.createElement("td");
      td1.setAttribute("colSpan","5");
      td1.setAttribute("align","center");
      td1.className = "formdata";
      td1.innerHTML = "<b>Container Load list</b>";
      tr1.appendChild(td1);
      tbody1.appendChild(tr1);
      childTab.appendChild(tbody1);

      var      tbody2      = document.createElement("tbody");
      var      tr2            = document.createElement("tr");
      tr2.className = "formdata";            

      var td2            = document.createElement("td");
      td.appendChild(document.createTextNode(' '));
      tr2.appendChild(td2);
      td2            = document.createElement("td");
      td2.innerHTML = "<b>Inc</b>";
      tr2.appendChild(td2);
      td2            = document.createElement("td");
      td2.innerHTML = "<b>Shipment No</b>";
      tr2.appendChild(td2);
      td2            = document.createElement("td");
      td2.innerHTML = "<b>Pieces Loaded</b>";
      tr2.appendChild(td2);
      td2            = document.createElement("td");
      td.appendChild(document.createTextNode(' '));
      tr2.appendChild(td2);
      tbody2.appendChild(tr2);
      childTab.appendChild(tbody2);
      childTab.setAttribute("border",1);
      childTab.setAttribute("cellspacing",0);
      childTab.setAttribute("cellpadding",0);
      //end

      tr.appendChild(td);
      tbody.appendChild(tr);
      tab.appendChild(tbody);
      createSubRow(idCounter);
      idCounter++;      
      counter++;
      if(counter!=0 && idCounter > 1)
      {
            for(i=1;i<=idCounter;i++)
            {
                  if(document.getElementById('addbut'+i)!=null)
                  {
                        document.getElementById('addbut'+i).style.visibility="hidden";
                        prevElement=i;
                  }
            }
            if(document.getElementById('addbut'+prevElement)!=null)
                  document.getElementById('addbut'+prevElement).style.visibility="visible";
      }
document.getElementById('UOW'+(idCounter-1)).value='KG';
document.getElementById('UOV'+(idCounter-1)).value='CBM';

      
      if(document.getElementById("containerSize"+(idCounter-1))!=null)
            document.getElementById("containerSize"+(idCounter-1)).focus();
}
function addSelectElement(idcounter,elementName,id,optionsList,optionsValues,className,tdFlag)
{
      myElement=document.createElement("select");
      myElement.setAttribute("name",elementName);
      myElement.setAttribute("id", id+idcounter);
      for(i=0;i<optionsList.length;i++)
      {
            if(optionsValues!=null && optionsValues!="")
                  myElement.appendChild(addOption(optionsList[i],optionsValues[i]));
            else
                  myElement.appendChild(addOption(optionsList[i]));
      }
      myElement.className = className;

      if(document.all)
            myElement.attachEvent("onchange",eventHandler);
      else
            myElement.setAttribute("onChange", "eventHandler('"+myElement.getAttribute("id")+"');");

      if(document.all)
            myElement.attachEvent("onfocus",eventHandler);
      else
            myElement.setAttribute("onFocus", "eventHandler('"+myElement.getAttribute("id")+"');");

      myElement.setAttribute("prevIndex","0");
      myElement.setAttribute("eventType","onChange");

      return myElement;
}
function addOption(optionStr,optionValue)
{
      var myOption=document.createElement("option");
      myOption.setAttribute("innerText",optionStr);
      if(optionValue!=null && optionValue!="")
            myOption.setAttribute("value",optionValue);
      else
            myOption.setAttribute("value",optionStr);
      myOption.text=optionStr;
      return myOption;
}
function createSubRow(index)
{
      tab = document.getElementById("sasDynChild"+index);      

      var parent = document.getElementById("parent"+index).value;
//      alert("parent:"+parent.value);
      var subIdCounter = tab.getAttribute("tableCounter");
      var subCounter = tab.getAttribute("tableCounter");
      
      var tbody      = document.createElement("tbody");
      tbody.setAttribute("id","tbody"+index+subIdCounter)
      var tr            = document.createElement("tr");
      tr.className="formdata";

      var td            = document.createElement("td");
      
      if(subIdCounter==1)
            td.appendChild(document.createTextNode(' '));
      else
      {
            myElement = addInputElement(subIdCounter,"","button","subdelbut"+index,"subdelbut","","<<","deleteSubRow();","","input");
            myElement.setAttribute("tableId",index);
            td.appendChild(myElement);
      }

      tr.appendChild(td);
      td            = document.createElement("td");
      td.appendChild(document.createTextNode(' '+subCounter+''));
      tr.appendChild(td);
      td            = document.createElement("td");
      myElement = addSelectElement(subIdCounter,"shipmentId"+parent,"shipmentId"+index,shipmentId,shipmentNo,"select");
      myElement.setAttribute("tableId",index);
      td.appendChild(myElement);
      td.appendChild(addInputElement(subIdCounter,"","hidden","shipmentNo"+index,"shipmentNo"+parent,"",shipmentNo[0],"","",""));
      tr.appendChild(td);
      td            = document.createElement("td");
      td.appendChild(addInputElement(subIdCounter,"5","text","shipmentPieces"+index,"shipmentPieces"+parent,"5","","","s","input"));
      td.appendChild(document.createTextNode(' of '));
//tr.appendChild(td);
      //td            = document.createElement("td");
      if(totPieces[0]==null)
            totPieces[0] = 0;

      td.appendChild(addInputElement(subIdCounter,"5","text","shipmentTotPieces"+index,"shipmentTotPieces"+parent,"5",totPieces[0],"","s","input","Y"));
      tr.appendChild(td);
      td            = document.createElement("td");
      myElement = addInputElement(subIdCounter,"","button","subaddbut"+index,"subaddbut","",">>","createSubRow();","","input")
      myElement.setAttribute("tableId",index);
      td.appendChild(myElement);
      tr.appendChild(td);
      tbody.appendChild(tr);
      tab.appendChild(tbody);
      subIdCounter++;      
      subCounter++;
      tab.setAttribute("tableCounter",subIdCounter);
      var prevElement;
      if(subCounter!=0 && subIdCounter > 1)
      {
            for(i=1;i<=subIdCounter;i++)
            {
                  if(document.getElementById('subaddbut'+index+i)!=null)
                  {
                        document.getElementById('subaddbut'+index+i).style.visibility="hidden";
                        prevElement=i;
                  }
            }
            if(document.getElementById('subaddbut'+index+prevElement)!=null)
                  document.getElementById('subaddbut'+index+prevElement).style.visibility="visible";
      }
}
function eventHandler()
{
      //alert("Id:"+event.srcElement.getAttribute("id"));
      //alert("Name:"+event.srcElement.name);
      var tmpId=event.srcElement.getAttribute("id").substr(6);
      var evtObj = event.srcElement;
      if(event.srcElement.getAttribute("eventType")=="click")
      {
            if(event.srcElement.name=="addbut")
            {
                  if(!document.getElementById("singleContainer").checked)
                        createRow();
            }
            else if(event.srcElement.name=="subaddbut")
            {
                  if(!document.getElementById("singleContainer").checked)
                        createSubRow(event.srcElement.getAttribute("tableId"));
            }
            else if(event.srcElement.name=="delbut")
            {
                  deleteRow(event.srcElement.getAttribute("id").substr(6));
            }
            else if(event.srcElement.name=="subdelbut")
            {
                  if(!document.getElementById("singleContainer").checked)
                        deleteSubRow(event.srcElement.getAttribute("tableId"),event.srcElement.getAttribute("id").substring(9));
            }
            else if(event.srcElement.name=="subdelbut")
            {
                  deleteRow(event.srcElement.getAttribute("id").substr(9));
            }
            else if(event.srcElement.name.indexOf("shipmentId")!=-1)
            {
                  //alert("999");
                  setShipmentDetails(event.srcElement.getAttribute("tableId"));
            }
      }
      //Added by RamaRao for validating the number field
      if(event.srcElement.getAttribute("eventType")=='blur')
      {
            if(event.srcElement.name=="weight")
            {
                  roundDecimalNumbers(document.getElementById(event.srcElement.getAttribute("id")),3,false,"",true);
            }
      }
      if(event.srcElement.name.indexOf("shipmentId")!=-1)
      {
            //alert(event.srcElement.getAttribute("id"));
            setShipmentDetails(event.srcElement.getAttribute("tableId"),event.srcElement.getAttribute("id"));
      }            
      return;
}
function setShipmentDetails(str,obj)
{
      var lastIndex = obj.substring(obj.indexOf("shipmentId")+10);
//      alert("lastIndex:"+lastIndex);
      var totalPiecesObj = document.getElementById("shipmentTotPieces"+lastIndex);
      var shipmentIdsObj = document.getElementById("shipmentId"+lastIndex);
      var shipmentNoObj = document.getElementById("shipmentNo"+lastIndex);
      if(shipmentIdsObj!=null && totalPiecesObj!=null)
      {
            totalPiecesObj.value = totPieces[shipmentIdsObj.selectedIndex];
            shipmentNoObj.value = shipmentNo[shipmentIdsObj.selectedIndex];
      }
}
function deleteRow(str)
{
      var tbody = document.getElementById('tbody'+str)
      tbody.removeNode(true);      
      counter--;
      var butStr = "addbut";
      for(i=1;i<=idCounter;i++)
      {
            if(document.getElementById(butStr+i)!=null)
                  prevElement=i;
      }
      if(document.getElementById(butStr+prevElement)!=null)
            document.getElementById(butStr+prevElement).style.visibility="visible";
}
function deleteSubRow(str,id)
{
      var tab = document.getElementById("sasDynChild"+str)
      subIdCounter = tab.getAttribute("tableCounter");
      var tbody = document.getElementById('tbody'+id)
      tbody.removeNode(true);      
      subCounter--;
      var butStr = "subaddbut"+str;

      for(i=1;i<=subIdCounter;i++)
      {
            if(document.getElementById(butStr+i)!=null)
                  prevElement=i;
      }
      if(document.getElementById(butStr+prevElement)!=null)
            document.getElementById(butStr+prevElement).style.visibility="visible";
}
function setIncrement()
{
      for(i=0;i<idCounter;i++)
      {
            
      }
}
function addInputElement(idcounter,maxLength,type,id,elementName,size,value,clickEvent,blurEvent,className,readOnly)
{
      myElement=document.createElement("input");
      myElement.setAttribute("onClick","alert('Presently Working only in NS,donno why???')")      //only ns
      myElement.setAttribute("name",elementName);
      myElement.setAttribute("type",type);
      myElement.setAttribute("id", id+idcounter);
      myElement.setAttribute("size", size);
      myElement.setAttribute("value", value);
      if(readOnly!=null && readOnly!="")
            myElement.setAttribute("readOnly", true);

      if(maxLength!=null && maxLength!="")
      {
            myElement.setAttribute("maxLength",maxLength);
      }

      if(className!=null && className!="")
            myElement.className=className;

      var myform=document.getElementsByTagName("form").item(0);
      myform.appendChild(myElement);

      if(clickEvent!=null && clickEvent!="")
      {
            myElement.setAttribute("eventType","click");
            if(document.all)
                  myElement.attachEvent("onclick",eventHandler);
            else
                  myElement.setAttribute("onClick", "eventHandler('"+myElement.getAttribute("id")+"');");
      }

      if(blurEvent!=null && blurEvent!="")
      {
            if(document.all)
                  myElement.attachEvent("onblur",eventHandler);
            else
                  myElement.setAttribute("onBlur", "eventHandler('"+myElement.getAttribute("id")+"');");
            myElement.setAttribute("eventType","blur");
      }

      return myElement;
}

function setAction()
{
      if(!validateFormData())
            return false;
      document.getElementById("NextOperation").value="Submit";
      document.getElementById("isSave").value="true";
      document.forms[0].submit();
}

function validateFormData()
{
      if(document.getElementById("operation").value=="Inquire")
            return true;
      toUpperCase();
      var arrShipmentNos = new Array();
      var arrNoOfPckgObjs = new Array();
      var arrNoOfPckgs = new Array();
      var arrTotalPieces = new Array();
      for(i=1;i<=idCounter;i++)
      {
            if(document.getElementById("containerType"+i)==null)
                  continue;
            var subTable      =      document.getElementById("sasDynChild"+i);
            var subIdCounter=      subTable.getAttribute("tableCounter");
            var containerType = document.getElementById("containerType"+i)
            var containerPrefix = document.getElementById("containerPrefix"+i)
            var containerPieces = document.getElementById("containerPieces"+i)
            var containerNumber = document.getElementById("containerNumber"+i)
            var sealNo1 = document.getElementById("sealNo1"+i)
            var sealNo2 = document.getElementById("sealNo2"+i)
            var sealNo3 = document.getElementById("sealNo3"+i)
            //var totalPieces = document.getElementById("shipmentPiecesTotPieces"+i).value;
            if(containerPrefix.value==0)
            {
                  alert("Enter Container prefix");
                  containerPrefix.focus();
                  return false;
            }
            if(containerNumber.value.length<=0)
            {
                  alert("Enter Container Number");
                  containerNumber.focus();
                  return false;
            }
            if(document.getElementById("operation").value=="Modify" && containerPieces.value==0)
            {
                  alert("Enter Container Pieces");
                  containerPieces.focus();
                  return false;
            }
            if(sealNo1.value.length<=0)
            {
                  alert("Enter Seal#1");
                  sealNo1.focus();
                  return false;
            }
            if(sealNo1.value.length>0 && sealNo2.value.length>0)
            {
                  if(sealNo1.value==sealNo2.value)
                  {
                        alert("Seal No"+sealNo2.value+" already selected");
                        sealNo2.focus();
                        sealNo2.select();
                        return false;
                  }
            }
            if(sealNo2.value.length>0 && sealNo3.value.length>0)
            {
                  if(sealNo2.value==sealNo3.value)
                  {
                        alert("Seal No"+sealNo3.value+" already selected");
                        sealNo3.focus();
                        sealNo3.select();
                        return false;
                  }
            }
            if(sealNo1.value.length>0 && sealNo3.value.length>0)
            {
                  if(sealNo1.value==sealNo3.value)
                  {
                        alert("Seal No"+sealNo3.value+" already selected");
                        sealNo3.focus();
                        sealNo3.select();
                        return false;
                  }
            }
            for(ii=0;ii<=idCounter;ii++)
            {
                  if(document.getElementById("sealNo1"+ii)==null || i==ii)
                        continue;
                  var containerNo = document.getElementById("containerNumber"+ii);
                  var sealNumber1            = document.getElementById("sealNo1"+ii);
                  var sealNumber2            = document.getElementById("sealNo2"+ii);
                  var sealNumber3            = document.getElementById("sealNo3"+ii);
                  var prefix            = document.getElementById("containerPrefix"+ii);
                  if(sealNo1.value.length>0 && sealNumber1.value.length > 0 && (sealNumber1.value==sealNo1.value))
                  {
                        alert("Seal Number "+sealNumber1.value+" already selected");
                        sealNumber1.focus();
                        sealNumber1.select();
                        return false;
                  }
                  if(containerNumber.value.length>0 && containerNo.value.length > 0 && (containerNo.value==containerNumber.value))
                  {
                        alert("Container Number "+containerNo.value+" already selected");
                        containerNo.focus();
                        containerNo.select();
                        return false;
                  }
            }
            var subTotalPieces = 0;
            if(containerType!=null)
            {
                  for(j=1;j<=subIdCounter;j++)
                  {
                        var shipmentIdObj = document.getElementById("shipmentId"+i+j);
                        if(shipmentIdObj==null)
                              continue;
                        subTotalPieces += document.getElementById("shipmentPieces"+i+j).value*1;

                        if(document.getElementById("shipmentPieces"+i+j).value==0)
                        {
                              alert("Enter No Of Packages for the Shipment "+document.getElementById("shipmentId"+i+j).value);
                              document.getElementById("shipmentPieces"+i+j).focus();
                              document.getElementById("shipmentPieces"+i+j).select();
                              return false;
                        }
                        //alert("sas");
                        
                        for(jj=0;jj<=subIdCounter;jj++)
                        {
                              if(document.getElementById("shipmentId"+i+jj)==null || j==jj)
                                    continue;
                              var shipmentIdObj1            = document.getElementById("shipmentId"+i+jj);
                              if(shipmentIdObj.value==shipmentIdObj1.value)
                              {
                                    alert("ShipmentId cannot be same for one container ");
                                    shipmentIdObj1.focus();
                              //      shipmentIdObj1.select();
                                    return false;
                              }
                        }
                        setShipmentDetails(document.getElementById("shipmentId"+i+j).getAttribute("tableId"),"shipmentId"+i+j);
                        //setShipmentDetails(document.getElementById(i+"shipmentId"+j));
                        arrShipmentNos[arrShipmentNos.length] = document.getElementById("shipmentId"+i+j);
                        arrNoOfPckgObjs[arrNoOfPckgObjs.length] = document.getElementById("shipmentPieces"+i+j);
                        arrNoOfPckgs[arrNoOfPckgs.length] = document.getElementById("shipmentPieces"+i+j).value;
                        arrTotalPieces[arrTotalPieces.length] = document.getElementById("shipmentTotPieces"+i+j).value;
                  }
                  
                  if(document.getElementById("operation").value=="Modify" && subTotalPieces!=containerPieces.value)
                  {
                        alert("Total container pieces should match the pieces per shipment");
                        document.getElementById("containerPieces"+i).focus();
                        document.getElementById("containerPieces"+i).select();
                        return false;
                  }
            }
      }
            var totalAllowed = 0;
      var totalSelected = 0;
      for(var i=0;i<arrShipmentNos.length;i++)
      {
            totalSelected = arrNoOfPckgs[i];
            totalAllowed  = arrTotalPieces[i]
            for(var j=0;j<arrShipmentNos.length;j++)
            {
                  if(i!=j && arrShipmentNos[i].value==arrShipmentNos[j].value)
                  {
                        totalSelected = totalSelected*1+arrNoOfPckgs[j]*1;
                  }
            }      
            //alert(":"+totalSelected+"!="+totalAllowed+":");
            if(totalSelected!=totalAllowed)
            {
                  alert("Total Packages Selected should be equal to "+totalAllowed+" for shipment "+arrShipmentNos[i].value);
                  arrNoOfPckgObjs[i].focus();
                  arrNoOfPckgObjs[i].select();
                  return false;
            }
            //alert(i+" arrShipmentNos "+arrShipmentNos[i]+" arrNoOfPckgs "+arrNoOfPckgs[i]+" arrTotalPieces "+arrTotalPieces[i]);
      }
      for(var k=0;k<shipmentNo.length;k++)
      {
            var existsFlag = true;
            for(var i=0;i<arrShipmentNos.length;i++)
            {
                  if(shipmentNo[k]!=arrShipmentNos[i].value)
                        existsFlag = false;
                  else
                  {
                        existsFlag = true;
                        break;
                  }
            }
            if(!existsFlag)
            {
                  alert("Enter Piece Details for Shipment "+shipmentId[k]);
                  return false;
            }
      }

      for(i=0;i<=idCounter;i++)
      {
            //alert(document.getElementById("sealNo1"+i));
            if(document.getElementById("sealNo1"+i)==null)
                  continue;
            var sealObj11 = document.getElementById("sealNo1"+i);
            var sealObj12 = document.getElementById("sealNo2"+i);
            var sealObj13 = document.getElementById("sealNo3"+i);
            for(j=0;j<=idCounter;j++)
            {
                  //alert(document.getElementById("sealNo1"+i));
                  if(document.getElementById("sealNo1"+j)==null)
                        continue;
                        
                  var sealObj21 = document.getElementById("sealNo1"+j);
                  var sealObj22 = document.getElementById("sealNo2"+j);
                  var sealObj23 = document.getElementById("sealNo3"+j);
                  if(i!=j && sealObj21.value.length>0 && (sealObj11.value==sealObj21.value || sealObj12.value==sealObj21.value || sealObj13.value==sealObj21.value || sealObj22.value==sealObj21.value || sealObj23.value==sealObj21.value))
                  {
                        alert("Seal No "+sealObj21.value+" already selected");
                        sealObj21.focus();
                        sealObj21.select();
                        return false;
                  }
                  if(i!=j && sealObj22.value.length>0 && (sealObj11.value==sealObj21.value || sealObj12.value==sealObj21.value || sealObj13.value==sealObj21.value || sealObj22.value==sealObj21.value || sealObj23.value==sealObj21.value))
                  {
                        alert("Seal No "+sealObj22.value+" already selected");
                        sealObj22.focus();
                        sealObj22.select();
                        return false;
                  }
                  if(i!=j && sealObj23.value.length>0 && (sealObj11.value==sealObj23.value || sealObj12.value==sealObj23.value || sealObj13.value==sealObj23.value || sealObj22.value==sealObj21.value || sealObj23.value==sealObj21.value))
                  {
                        alert("Seal No "+sealObj23.value+" already selected");
                        sealObj23.focus();
                        sealObj23.select();
                        return false;
                  }
            }
      }
      disableForm(new Array("save","Submit","Refresh"));
      return true;
}
function checkSingleContainer()
{
      if(counter >2 && document.getElementById("singleContainer").checked==true)
      {
            alert("There are more than one container please remove one");
            document.getElementById("singleContainer").checked = false;
      }
      else
      {
            var parentRowId = (counter-1);
            var myTable=document.getElementById("sasDynChild"+parentRowId);
            var subCounter = myTable.getAttribute("tableCounter");
            var subIdCounter = myTable.getAttribute("tableCounter");
            var newShipmentIds = new Array();
            var totalPieces = 0;
            var totalWeight= 0;
            var totalVolume = 0;
            for(var j=0;j<shipmentId.length;j++)
            {
                  totalPieces += totPieces[j]*1;
                  totalWeight += shipmentWt[j]*1;
                  totalVolume += shipmentVol[j]*1;
                  var flag = true;
                  for(var i=0;i<=subIdCounter;i++)
                  {
                        if(document.getElementById("shipmentId"+parentRowId+i)==null)
                        {
                              //flag = false; //Commented by T.Vijay Kumar for Issue 11258
                              continue;
                        }
                        if(shipmentId[j]==document.getElementById("shipmentId"+parentRowId+i).value)
                        {
                              document.getElementById("shipmentPieces"+parentRowId+i).value = document.getElementById("shipmentTotPieces"+parentRowId+i).value;
                              if(document.getElementById("singleContainer").checked==true)
                              {
                                    document.getElementById("shipmentId"+parentRowId+i).disabled = 'disabled';
                                    document.getElementById("shipmentPieces"+parentRowId+i).readOnly = true;
                                    document.getElementById("shipmentTotPieces"+parentRowId+i).readOnly = true;
                              }
                              else
                              {
                                    document.getElementById("shipmentId"+parentRowId+i).disabled = '';
                                    document.getElementById("shipmentPieces"+parentRowId+i).readOnly = false;
                                    document.getElementById("shipmentTotPieces"+parentRowId+i).readOnly = true;
                              }

                              flag = false;
                              break;
                        }
                  }
                  if(flag)
                        newShipmentIds[newShipmentIds.length]=shipmentId[j];
            }
            //alert("totalWeight "+totalWeight);
            if(document.getElementById("containerPieces1")!=null)
            {
                  document.getElementById("containerPieces1").value = totalPieces;
                  document.getElementById("weight1").value = totalWeight;
                  document.getElementById("volume1").value = totalVolume;
                  roundDecimals(document.getElementById("weight1"),2)
                  roundDecimals(document.getElementById("volume1"),3)
            }
            //alert(newShipmentIds);
            for(var i=0;i<newShipmentIds.length;i++)
            {
                  createSubRow(parentRowId);
                  document.getElementById("shipmentId"+parentRowId+subIdCounter).value = newShipmentIds[i];
                  setShipmentDetails(document.getElementById("shipmentId"+parentRowId+subIdCounter).getAttribute("tableId"),"shipmentId"+parentRowId+subIdCounter);
//                  setShipmentDetails(document.getElementById("shipmentId"+parentRowId+subIdCounter));
                  document.getElementById("shipmentPieces"+parentRowId+subIdCounter).value = document.getElementById("shipmentTotPieces"+parentRowId+subIdCounter).value;

                  if(document.getElementById("singleContainer").checked==true)
                  {
                        document.getElementById("shipmentId"+parentRowId+subIdCounter).disabled = 'disabled';
                        document.getElementById("shipmentPieces"+parentRowId+subIdCounter).readOnly = true;
                        document.getElementById("shipmentTotPieces"+parentRowId+subIdCounter).readOnly = true;
                  }
                  else
                  {
                        document.getElementById("shipmentId"+parentRowId+subIdCounter).disabled = '';
                        document.getElementById("shipmentPieces"+parentRowId+subIdCounter).readOnly = false;
                        document.getElementById("shipmentTotPieces"+parentRowId+subIdCounter).readOnly = true;
                  }

                  subIdCounter++;
                  subCounter++;
                  //assignContainerData(idcounter);
            }
      }
}
function setupData()
{
      var consoleType = "LCL";
      var currentRow            = 0;
      var subCurrentRow      = 0;
createRow('saDyn');
currentRow++;
subCurrentRow=1;
document.getElementById('containerSize'+currentRow).value = '40'
document.getElementById('containerType'+currentRow).value = 'STD'
document.getElementById('containerPrefix'+currentRow).value = '6'
document.getElementById('containerNumber'+currentRow).value = '868'
document.getElementById('UOW'+currentRow).value = 'KG'
document.getElementById('UOV'+currentRow).value = 'CBM'
document.getElementById('parent'+currentRow).value = currentRow
document.getElementById('weight'+currentRow).value = '0.0'
document.getElementById('volume'+currentRow).value = '0.0'
document.getElementById('FCRNo'+currentRow).value =''
document.getElementById('sealNo1'+currentRow).value = '79'
document.getElementById('sealNo2'+currentRow).value = ''
document.getElementById('sealNo3'+currentRow).value = ''
document.getElementById('shipmentId'+currentRow+subCurrentRow).value = '70104438'
document.getElementById('shipmentPieces'+currentRow+subCurrentRow).value = '35'
setShipmentDetails(document.getElementById('shipmentId'+currentRow+subCurrentRow).getAttribute('tableId'),'shipmentId'+currentRow+subCurrentRow)
document.getElementById('containerPieces'+currentRow).value = '35'
createRow('saDyn');
currentRow++;
subCurrentRow=1;
document.getElementById('containerSize'+currentRow).value = '45'
document.getElementById('containerType'+currentRow).value = 'STD'
document.getElementById('containerPrefix'+currentRow).value = '75'
document.getElementById('containerNumber'+currentRow).value = '757'
document.getElementById('UOW'+currentRow).value = 'KG'
document.getElementById('UOV'+currentRow).value = 'CBM'
document.getElementById('parent'+currentRow).value = currentRow
document.getElementById('weight'+currentRow).value = '0.0'
document.getElementById('volume'+currentRow).value = '0.0'
document.getElementById('FCRNo'+currentRow).value =''
document.getElementById('sealNo1'+currentRow).value = '46'
document.getElementById('sealNo2'+currentRow).value = '4'
document.getElementById('sealNo3'+currentRow).value = ''
document.getElementById('shipmentId'+currentRow+subCurrentRow).value = '70104440'
document.getElementById('shipmentPieces'+currentRow+subCurrentRow).value = '103'
setShipmentDetails(document.getElementById('shipmentId'+currentRow+subCurrentRow).getAttribute('tableId'),'shipmentId'+currentRow+subCurrentRow)
document.getElementById('containerPieces'+currentRow).value = '103'

      if(idCounter==1)
            createRow('sasDyn');
      //alert("idcounter:"+idcounter);
      // Changed by Raghu Ram for Issue No : 6342
      //if(idCounter <= 2 && document.getElementById("operation").value!="Add")
      //if(idCounter <= 2 )
      //Modified by T.Vijay Kumar
      if('Y' == '' && document.getElementById("operation").value!="Inquire")
      {
            document.getElementById("singleContainer").checked = true;
            checkSingleContainer();
      }
      else if(document.getElementById("operation").value=="Inquire" && idCounter <= 2)
      {
            document.getElementById("singleContainer").checked = true;
            checkSingleContainer();
      }
}

function handleErrors()
{
      var errorFields = new Array();

      if(errorFields.length>0)
            alert("Incorrect Values");
      for(var i=0;i<errorFields.length;i++)
      {
            if(document.getElementById(errorFields[i]).parentNode!=null)
                  document.getElementById(errorFields[i]).parentNode.style.color='red'
            //if(document.getElementById(errorFields[i]+"Label")!=null)
                  //document.getElementById(errorFields[i]+"Label").innerHTML = "<font color=red>"+document.getElementById(errorFields[i]+"Label").innerHTML+"</font>";
      }      
}

function intialize()
{
            displayTabPane();
}
var defaultSubmitButtonId = "image6";

function makeReadOnly()
{
            var tableObj = document.getElementById("containerTable");
      
            for(var i=1;i<tableObj.idcounter;i++)
            {
                  
                  if(document.getElementById("containerSize"+i)!=null)
                  {
                        //document.getElementById("number"+i).readOnly = true;
                        alert("aaa")
                        document.getElementById("containerSize"+i).disabled = true;
                        document.getElementById("containerType"+i).disabled = true;
                        
                        document.getElementById("containerPrefix"+i).readOnly = true;
                        document.getElementById("containerNo"+i).readOnly = true;


                        document.getElementById("commodityCode"+i).readOnly = true;
                        document.getElementById("commCodeButton"+i).disabled = true;
                        document.getElementById("noOfPieces"+i).readOnly = true;
                        document.getElementById("weight"+i).readOnly = true;
                        document.getElementById("containerUOW"+i).disabled = true;
                        document.getElementById("volume"+i).readOnly = true;
                        document.getElementById("containerUOV"+i).disabled = true;
                        document.getElementById("sealNo1"+i).disabled = true;
                        document.getElementById("sealNo2"+i).disabled = true;
                        document.getElementById("sealNo3"+i).disabled = true;
                         

                  }
            }

}

</SCRIPT>

            
 

<SCRIPT LANGUAGE="JavaScript">
var tabPaneXmlTagName = "";
var disableTabs = false;

//s.v. srinivas for locking customs screen after the approval of customs 6/1/2004
var lock      =      'null';
//end of s.v. srinivas

function displayTabPane(disableTabsFlag)
{
      disableTabs = disableTabsFlag;
      tabPaneXmlTagName = "MHBL";
      var xmlFile = "html/TabPane.xml";
      if (document.implementation && document.implementation.createDocument)
      {
            tabPaneXmlDoc = document.implementation.createDocument("", "", null);
            tabPaneXmlDoc.onload = extractTabPane;
      }
      else if (window.ActiveXObject)
      {
            tabPaneXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            tabPaneXmlDoc.onreadystatechange = function ()
                                                                         {
                                                                               if (tabPaneXmlDoc.readyState == 4)
                                                                               {
                                                                                     extractTabPane();
                                                                               }                                                                                    
                                                                         };
       }
      else
      {
            alert('Your browser can\'t handle this script');
            return;
      }
      tabPaneXmlDoc.load(xmlFile);
}
var imageObjIdsList      = new Array();
function extractTabPane()
{
      var totalTabPaneHTML = "";
      var tagName = tabPaneXmlTagName;
      var x = tabPaneXmlDoc.getElementsByTagName(tagName);
      var imageStr = "";
      for (i=0;i<x.length;i++)
      {
            var imgIndex            = getAttributeValue(x[i],"ImageIndex",0);
            var imgOperation      = getAttributeValue(x[i],"Operation",null);
            var accessKey            = getAttributeValue(x[i],"AccessKey",0);
            var isDisabled            = getAttributeValue(x[i],"disabled",false);
            if(disableTabs)
                  isDisabled = disableTabs;
            var imgStr = "";
            imgIndex = i;
            if(latestNextOperation==imgOperation)
            {
                  imgStr += "<img alt='"+getAttributeValue(x[i],"tabName","")+"' imageIndex='"+imgIndex+"' id='image"+imgIndex+"'";
                  imgStr += " src='"+getChildAttributeValue(x[i],"Active-Image","")+"'";
            }
            else
            {
                  //i==lock is added by s.v. srinivas 6/1/2004
                  
                  if(isDisabled || i==lock)
                  {
                        imgStr += "<img alt='"+getAttributeValue(x[i],"tabName","")+"' imageIndex='"+imgIndex+"' id='image"+imgIndex+"'";      
                        imgStr += " src='"+getChildAttributeValue(x[i],"Inactive-Image","")+"'";
                  }
                  else
                  {
                        imgStr += "<input type=image alt='"+getAttributeValue(x[i],"tabName","")+"  [Alt+"+accessKey+"]' imageIndex='"+imgIndex+"' id='image"+imgIndex+"' accessKey='"+accessKey+"' onClick='return changeNextOperation(\""+imgOperation+"\");' activeImage='"+getChildAttributeValue(x[i],"Active-Image","")+"' inactiveImage='"+getChildAttributeValue(x[i],"Inactive-Image","")+"'";      
                        imgStr += " src='"+getChildAttributeValue(x[i],"Inactive-Image","")+"'";
                  }
            }
            imgStr += ">";
            imageObjIdsList[imageObjIdsList.length] = "image"+imgIndex;
            totalTabPaneHTML += "<td class=formdata noWrap >"+imgStr+"</td>";
      }
      //alert(totalTabPaneHTML);
      writeContent(totalTabPaneHTML);
}
function getChildAttributeValue(x,attribName,defaultValue)
{
      var nodeValue = defaultValue;
      for (j=0;j<x.childNodes.length;j++)
      {
            if(x.childNodes[j].nodeName.toUpperCase()==attribName.toUpperCase())
                  nodeValue = x.childNodes[j].firstChild.nodeValue;
      }
      return nodeValue;
}
function getAttributeValue(x,attribName,defaultValue)
{
      for(var i=0;i<x.attributes.length;i++)
      {
            if(attribName==x.attributes[i].name)
                  return x.attributes[i].value;
      }
      return defaultValue;
}
var latestNextOperation = "Containers";
function changeNextOperation(nextOperation)
{
      if(this.validateTabClick!=null)
      {
            if(!validateTabClick(nextOperation))
                  return false;
      }
      if(nextOperation==null || nextOperation==latestNextOperation)
            return false;
      document.getElementById("nextOperation").value = nextOperation;
      return true;
}
function writeContent(totalTabPaneHTML)
{
      var htmlStr = "";
      htmlStr += '<tr>';
      htmlStr += totalTabPaneHTML;
      htmlStr += '<td width=75% class=formdata>&nbsp;</td>';
      htmlStr += '</tr>';
      htmlStr += '<input type="hidden" name="NextOperation" id="NextOperation" value="Containers">'
      document.getElementById("includeDIV").innerHTML = htmlStr;
      //document.getElementById("includeDIV").className = "formdata";
      //document.getElementById("includeDIV").style.marginTop = "1.5mm";
      //document.getElementById("includeDIV").style.paddingTop = "1mm";
}
function displayStandardPageHeader(standardPageHeaderId)
{
      if(standardPageHeaderId==null)
            standardPageHeaderId = "standardPageHeader";
      var standardPageHeaderObj = document.getElementById(standardPageHeaderId);
      if(standardPageHeaderObj==null)
            return;
      var htmlStr = "";
      htmlStr            += "<table width=100% cellpadding=2 cellspacing=1>";
      htmlStr            += "<tr>";
      htmlStr            += "<td width=10% class=formdata>User:</td>";
      htmlStr            += "<td width=20% class=formdata>ANIL</td>";
      htmlStr            += "<td width=15% class=formdata>Station:</td>";
      htmlStr            += "<td width=15% class=formdata>BOM</td>";
      //htmlStr            += "<td width=15% class=formdata>Date:</td>";
      //htmlStr            += "<td width=15% class=formdata>12MAY05</td>";
      htmlStr            += "</tr>";
      htmlStr            += "</table>";
      standardPageHeaderObj.innerHTML = htmlStr;
}
function handleUserKeyPressEvents(e)
{
      try
      {
            var whichCode    = (window.Event) ? e.which : event.keyCode;            
            if(whichCode==13)
            {
                  if (event.srcElement.type=="text" || event.srcElement.type=="radio" || event.srcElement.type=="checkbox")
                  {
                        event.returnValue = false;
                        document.getElementById(defaultSubmitButtonId).click();
                  }
                  //commented by D.S.S.Prasad       for issueNo 6761
                  /*else
                  {
                        return false;      
                  }*/
            }
      }
      catch(e){}
}
document.onkeypress = handleUserKeyPressEvents;
</SCRIPT>

<script  src="html/eSupplyDateValidation.jsp"></script>
<script language="javascript" src="html/eSupply.js"></script>
<link rel="stylesheet" href="eagle.css">
<body onLoad="intialize();setupData();handleErrors()">
<form method=post action="" onSubmit="return validateFormData()">
<div id="mainDiv" style="visibility:visible;position:absolute;">      
<table width="760" border="1" cellspacing="0" cellpadding="0" bordercolor="#b3b3d9">
            <tr>
                  <td valign="top" bgcolor="#FFFFFF">
                        <table width="760" border="0" cellspacing="1" cellpadding="2">
                              <tr class='formlabel'>
                                    <td colspan="4">Consol Container 004 - houseModify</td>
                              </tr>
                        </table>
                        <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#b3b3d9">
                              <tr>
                                    <td width="100%">
                                          
 







                  <table width="100%" border="0" cellspacing="1" cellpadding="2">
                        <tr class='formdata'>
                              <td>User Id<br>
                                    <input type="hidden" name="userId" value="ANIL"> ANIL
                              </td>
                              <td>Origin Station<br>
                                    <input type="hidden" name="origin" value="BOM" >BOM
                              </td>
                              <td>Destination Station<br>
                                    <input type="hidden" name="destination" value="DEL" >DEL<input type="hidden" name="sType" value="House" >
                              </td>

                              <td>Assembly Type<br></td>

                              <td>Load Type<br>
                                    <input type="hidden" name="cType" value="FCL" >FCL
                              </td>
                              <td>Created Date<br>
                                    <input type="hidden" name="cDate" value="11MAY05" >11MAY05
                              </td>
                              <td>Shipment Number<br>
                                    
                                    <input type="hidden" name="sNumber" value="70104456" >70104456
                              </td>
                              <td>File Number<br>
                                    <input type="hidden" name="fNumber" value="70104456" >70104456
                              </td>
                        </tr>
                  </table>

      </td>
    </tr>
  </table>
 <table  class='formlabel' border="0" cellspacing="0" cellpadding="0" width=100%>
            <div id=includeDIV class=formdata>&nbsp;</div>
            <tr>
                  <td class=formdata colspan="4"> <font color="red" size="2"><b>  </b></font> </td>
            </tr>
        </table>
      <table width="760" border="0" cellspacing="1" cellpadding="2">
            <tr class='formdata'>
                  <td colspan="6">
              <p align="right"><input type="checkbox" name="singleContainer" value="Y" onClick="checkSingleContainer()">Use
          Single Container</p>
            </td>
            </tr>
      </table>
      <table width="760" border="0" cellspacing="1" cellpadding="2">
            <tr class='formlabel'>
                  <td colspan="6">
              <p align="left"><b>Consol Container Details</b></p>
            </td>
            </tr>
      </table>
      <table id="sasDyn" width="760"  border=0 cellspacing="1" cellpadding="2">
            <tr class='formdata'>
                  <td rowspan="2" >&nbsp;</td>
                  <td rowspan="2" >&nbsp;</td>
                  <td colspan="4">
              <p align="center"><b>Container Details</b></p>
 </td>
                  <td rowspan="2">
              <p align="center"><font color="#3300CC"><b>Pieces</b></font></p>
            </td>
                  <td rowspan="2">
              <p align="center"><b>Weight</b></p>
            </td>
                  <td rowspan="2">
              <p align="center"><b>Volume</b></p>
            </td>
                  <td rowspan="2">
              <p align="center"><font color="#3300CC"><b>Seal#1</b></font></p>
            </td>
                  <td rowspan="2">
              <p align="center"><b>Seal#2</b></p>
            </td>
                  <td rowspan="2">
              <p align="center"><b>Seal#3</b></p>
            </td>
                  <td rowspan="2" >&nbsp;</td>
            </tr>                              
            <tr class='formdata'>
                  <td>
              <p align="center"><font color="#3300CC"><b>Size</b></font> </td>
                  <td>
              <p align="center"><font color="#3300CC"><b>Type</b></font> </td>
                  <td>
              <p align="center"><font color="#3300CC"><b>Prefix</b></font> </td>
                  <td>
              <p align="center"><font color="#3300CC"><b>Number</b></font></p>
            </td>
            </tr>                              
      </table>

      <table width="760" border="0" cellspacing="1" cellpadding="2">
            <tr class='formdata'>
                <td width=380><font color="Blue">Blue</font> Denotes Mandatory</td>
            <td width=380>
                          <input type="hidden" name="nextTaskName" id="nextTaskName" value="Carrier">
                        <input type="hidden" name ="operation" id="operation" value='houseModify'>
                        <input type="hidden" name="taskName"                  id="taskName"            value="Containers">
                          <input type="hidden" name="isSave" id="isSave" value="">
                        <input type="submit" tabindex=43 class=input value="Refresh" name="Refresh" id="Refresh" onClick="changeNextOperation('Refresh')"  >      
                        <input type="submit" id=save tabindex=43 class=input value="Save &amp; Exit"  id="SaveAExit"  onClick="setAction('SNE')"   >      


                        
                              <input type="submit" class=input name="Submit" id="Submit" value="ENTER" onClick="changeNextOperation('Summary');">
                  
            </tr>
      </table>
</td>
</tr>
      </table>

</div>
<div id="commonDIV" style="visibility:hidden;position:absolute;">&nbsp;
      <iframe id=iframe1 width=850 height=600 border=0 src="about:blank">
      </iframe>
</div>
</form>
</body>
</html>


0
chaitu chaitu
Asked:
chaitu chaitu
  • 4
  • 4
  • 3
1 Solution
 
chaitu chaituAuthor Commented:
in  Add mode all the rows will be enabled(its working fine) but in view mode all the fields should be disabled.
0
 
NETTY4Commented:
So you say, on clicking on [>>] button should the new fields be disabled?
How would they become enabled again?
0
 
NETTY4Commented:
How do you change the Mode?
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
chaitu chaituAuthor Commented:
we have drop down tabs in the menu liek add,modify,view modes;this is server side process;

when user clicks add tab all the fields in this screen should be enabled
when user clicks modify tab all the fields in this screen should be disabled
0
 
archrajanCommented:
To just disable all form elements u can use this

function disableall()
{
var frm = document.formname
for(i=0; i <frm.elements.length;i++)
{
frm.elements[i].disabled = true;
}
}

to enable:
function enableall()
{
var frm = document.formname
for(i=0; i <frm.elements.length;i++)
{
frm.elements[i].disabled = false;
}
}
0
 
NETTY4Commented:
So "add tab" is the [>>] button.
What is then the "modify tab" clickable point?
0
 
chaitu chaituAuthor Commented:
hi archrajan ,

ur code works but in that screen i have refresh ,save&exit and enter buttons are there;those button shouldn't disabled;in the above code how will u modify?
0
 
NETTY4Commented:
Also be aware that disabled form fields are NOT!!! sent to server at submit time!
0
 
archrajanCommented:
U give a class to those buttons say
the class is given like this

<input type = "button" class = "no" name = "save">...

then u can modify the script like

function disableall()
{
var frm = document.formname
for(i=0; i <frm.elements.length;i++)
{
if(frm.elements[i].className != 'no')
frm.elements[i].disabled = true;
}
}
0
 
archrajanCommented:
or if u do not want to give class names u have to manually do this:

function disableall()
{
var frm = document.formname
for(i=0; i <frm.elements.length;i++)
{
if(frm.elements[i].name != 'save' && frm.elements[i].name != 'refresh' && frm.elements[i].name != 'enter')
frm.elements[i].disabled = true;
}
}
0
 
archrajanCommented:
>>> Also be aware that disabled form fields are NOT!!! sent to server at submit time!
to over come this
u can do the enableall function to enable all the form elements in the onsubmit event of ur form tag
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now