I work on java script i display data on gridview using javascript and it display success on gridview gvResults using function GET_WORLD_BANK_LICN_DATA_REP()
so data display success on gridview gvResults using function below without any issue
my issue how to pass list of selected P_LICNS_CURInfo[i].LICN_CIVIL_ID that have checkbox checked true from gridview to button
as separated comma to function getselected_civilid when press button btnRequestSearch
so suppose i display data and select checkbox checked for P_LICNS_CURInfo[i].LICN_CIVIL_ID as 1245,4321,7891,9918
then it will passed to function getselected_civilid() as "1245","4321","7891","9918" when press button below
function getselected_civilid()
{
}
function GET_WORLD_BANK_LICN_DATA_REP() {
debugger
var P_ACT_ID_LIST = $('#ddl_activities').val();
var P_LICN_COUNT = $('#txtcountlicense').val();
var P_EXPIRY_YEAR = $('#txt_year').val();
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "../BusinessLayer/WebMethods.asmx/GET_WORLD_BANK_LICN_DATA_REP",
data: "{'P_ACT_ID_LIST':'" + P_ACT_ID_LIST + "','P_LICN_COUNT':'" + P_LICN_COUNT + "','P_EXPIRY_YEAR':'" + P_EXPIRY_YEAR + "'}",
dataType: "json",
beforeSend: function (xhr) {
xhr.setRequestHeader("STicket", MYLIBRARY.ReturnTicket());
Loading("????? ?????", "????????? ?? ??????? . . . ");
$("#gvResults").empty();
},
success: function (Result) {
CloseLoading();
$.each(Result.d, function (key, value) {
if (value.Status == "1") {
if (value.P_LICNS_CURInfo != null) {
if (value.P_LICNS_CURInfo.length > 0) {
var rowNo = 0;
for (var i in value.P_LICNS_CURInfo) {
if (rowNo == 0) {
$("#gvResults").append("? ??? ????? ??????? ??? ??????? ??? ????? ?????? ?????? ???????? ???????? ?????? ??? ?????? ?????? ???????? ??? ??????? ??????? ????? ????? ??????? ??????? ??? ???????? ?????? ?????????? ");
}
var row = " " + "" +
(rowNo + 1) + " " +
value.P_LICNS_CURInfo[i].comm_book_no + " " +
value.P_LICNS_CURInfo[i].LICN_COMM_NO + " " +
value.P_LICNS_CURInfo[i].LICN_CIVIL_ID + " " +
value.P_LICNS_CURInfo[i].LEGAL_STRACTURE_DESC + " " +
value.P_LICNS_CURInfo[i].ADDRESS_GOV_DESC + " " +
value.P_LICNS_CURInfo[i].SECTOR_DESC + " " +
value.P_LICNS_CURInfo[i].INT_ACT_CODE + " " +
value.P_LICNS_CURInfo[i].COMP_NAME + " " +
value.P_LICNS_CURInfo[i].ADDRESS_DESC + " " +
value.P_LICNS_CURInfo[i].ADDRESS_AUTO_NO + " " +
value.P_LICNS_CURInfo[i].ADDRESS_CITY + " " +
value.P_LICNS_CURInfo[i].PHONE_NO + " " +
value.P_LICNS_CURInfo[i].MAIL + " " +
" ";
row = $(row).hide();
$('#gvResults').append($(row));
rowNo++;
$(row).fadeIn(1000);
}
}
}
}
else {
ModelSuccessDanger('???? !!', value.StatusDesc, '0', null);
}
});
},
error: function (msg, status) {
CloseLoading();
if (status === "error") {
var errorMessage = $.parseJSON(msg.responseText);
ModelSuccessDanger('???? !!', errorMessage.Message, '0', null);
}
}
});
}
Naimish MakwanaPosted May 15, 2024, 4:03 AM
You can modify your
getselected_civilidfunction to get all checked checkboxes and their values. Here’s how you can do it:In this code, we’re using jQuery to select all checked checkboxes with the name
statusCheckbox. We then iterate over each of these checkboxes, pushing their values into theselectedCivilIdsarray. Finally, we join the array into a comma-separated string.Please replace the
console.logstatement with your desired function call, passingcommaSeparatedCivilIdsas an argument. Remember to include the quotation marks around each ID if your function requires them. You can do this by modifying the push line in the each function toselectedCivilIds.push('"' + $(this).val() + '"');. This will add the quotation marks around each ID.Please note that this code assumes that the value of each checkbox is the
LICN_CIVIL_IDyou want to pass to the function. If this is not the case, you may need to modify the code to suit your needs. Also, ensure that jQuery is properly included in your project as this code relies on it.