mardi 20 novembre 2018

How to concatenate/remove string if a checkbox is checked or unchecked in Jquery?

Currently I am working on Skelta BPM software which uses Jquery as scripting language.

The trouble I am facing is that I want all the JobID value to be displayed in the textbox whenever they are checked and to remove the specific JobID value which is unchecked.I dont know how to achieve this.

var JobID = "";

//control.findByXmlNode("isSelected").value="1";

if (currentRowValue === undefined )
{
        control.findById("T1").value = "";
}


if (currentRowValue !== undefined )
{
  //control.findById("T1").value+=currentRowValue.JobID+",";
  
   if(control.findById("T1").value !== currentRowValue.JobID+",")
    {
        control.findById("T1").value+=currentRowValue.JobID+",";  
    }  
    
}
else
{
 control.findById("T1").value ="";

  var grid = $("[controlid = G1");
  var allRows = grid.find("tbody")[0].children;
  var Id = "";
  var isChecked = false;
  if(allRows.length > 0)
  {
    ko.utils.arrayForEach(allRows, function(eachRow)
                          {
      isChecked = $(eachRow).find('input:checkbox:first').prop('checked');

      if(isChecked)
      {        
        Id +=$(eachRow).find("JobId").text()+ "," ;   
                var gridControl = control.findById("G1");
        var rowData = SFU.getGridValue(gridControl);
        //control.findByXmlNode("Textinput1").value = rowData.Tag;   
        Id += rowData[0].vwApproveCnS.JobID + ",";
      }   
     
    });
    Id = Id.substr(1);

    if(control.findById("T1").value !== Id)
    {
        control.findById("T1").value = Id;  
    }
   
  }

}

if(isChecked)
{
  
  control.findByXmlNode("isSelected").value="1";
}
else
{
  control.findByXmlNode("isSelected").value="0";
}

//----------------------------------------------------------


if (control.findByXmlNode("isSelected").value=="1")
{
  control.findById("F2").visible=true;
  control.findById("F1").visible=true;
}

enter image description here




Aucun commentaire:

Enregistrer un commentaire