// function for checkbox click
function updatePermission(checkbox) {
const PermissionId = parseInt(checkbox.id);
const RoleId = getqsValue();
updatePermAPI(PermissionId, RoleId);
}
// get role id
function getqsValue() {
const urlParm = new URLSearchParams(window.location.search);
return urlParm.get('id');
}
function updatePermAPI(PermissionId, RoleId) {
const permUrl = `${window.location.origin}/api/roles/updatepermission`;
const method = "POST";
const data = {
PermissionId: PermissionId,
RoleId: RoleId
}
console.log("API URL:", permUrl); // Log the complete API URL
fetch(permUrl, {
method: method,
body: JSON.stringify(data),
headers: {
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => {
console.log(data); // Log the response data
})
.catch(error => {
console.error(error); // Log the error
});
}
Calling an passing data to a POST API
on button click add text boxes and delete script
<button onclick="addField()" class="btn btn-outline-primary mb-3 btn-sm" type="button">+ Add Field</button>
<div id="fieldSection" class="mb-3"></div>
let fieldCount = 0;
function addField() {
fieldCount++;
const textboxName = `newfield_${fieldCount}`;
const textbox = document.createElement("input");
textbox.type = "text";
textbox.name = textboxName;
textbox.classList.add("form-control", "mb-2");
// Remove button
const removeBtn = document.createElement("button");
removeBtn.textContent = "X";
removeBtn.classList.add("btn", "btn-sm", "btn-outline-danger");
removeBtn.addEventListener("click", () => {
removeField(textboxName);
});
const fieldContainer = document.createElement("div");
fieldContainer.classList.add("fieldContainer");
fieldContainer.appendChild(textbox);
fieldContainer.appendChild(removeBtn);
const fieldSection = document.getElementById("fieldSection");
fieldSection.appendChild(fieldContainer);
}
function removeField(textboxName) {
const removable = document.querySelector(`input[name="${textboxName}"]`).parentNode;
const fieldSection = document.getElementById("fieldSection");
fieldSection.removeChild(removable);
}
Best Torrent Colud - seedr.cc
https://www.seedr.cc/ is one of the best or else the best ever torrent cloud which you can use free up to 2 GB limit. No other torrent cloud gives you this advantage. This is the most secure way to download torrent files to your personal computer. you can view files online without downloading. This is an amazing feature of this torrent cloud. This is one of the fastest way to download your files too. Seedr introduces you to a new era of torrent downloading. This torrent cloud elable you to download torrent files directly from the cloud without installing any software like utorrent or bittorrent. This reduce the hassle of using your computer connecting to a torrent seed network and reduce the damage and save your mobile data.