Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: ArturoRobles

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#828863
Hello,

I have checkgroup, i want when select checkboxes in checkgroup, after click button, this Items in grid.
every selected items(key and label=value and name), show in one row grid.

everybody can help me?
//*************************
my code is:

$("#addToList").click( function() {
var arrCheck = document.getElementsByName('form[checkgroupVar001][]');
var report = "";
var count=0;
for (var i = 0; i < arrCheck.length; i++)
{


if (arrCheck.checked)

report += arrCheck.value;
var aLabels = JSON.parse($("#checkgroupVar001").getText());


if (arrCheck.checked === true){
count++;


}

}

var client = $("#clientName").getValue();
var service = $("#typeOfService").getValue();
var hasContract = $("#hasContract").getValue();
var startDate = $("#contractStartDate").getValue();
if (client == '') {
alert("Please add a client name");
return;
}
else if (hasContract == "1" && startDate == '') {
alert("Please set the Contract Start Date");
return;
}

for (var j = 1; j <= count; j++){

var aData = [
{value: client},
{value: service},
{value: hasContract},
{value: startDate},
{value: report},
{value: aLabels}

];


$("#clientsList").addRow(aData);

}

//clear form:
$("#clientName").setValue('');
$("#typeOfService").setValue('');
$("#hasContract").setValue('0');

//workaround for clearing date fields:
$("[id='form[contractStartDate]']").val('');
$("[id='form[contractStartDate_label]']").val('');
getFieldById("contractStartDate").model.attributes.data.label='';
getFieldById("contractStartDate").model.attributes.data.value='';
});

function deleteList() {
var oGrid = $("#clientsList"); //set to the ID of the grid
var iRow = oGrid.getNumberRows();
for (; iRow > 0; iRow--) {
oGrid.deleteRow(iRow);
}
}

$("#clearList").click(deleteList); //clear grid when clicking "clearList" button
deleteList(); //clear grid when the Dynaform loads
Attachments
1.jpg
1.jpg (66.43 KiB) Viewed 91 times
rights management

Smartwatches have moved to a different approach as[…]

Hi, Check below link an example see if able to he[…]

Hi there, Found an example for you, kindly read […]

Hi, Very good Please describe your working method […]