Skip to content
BASE DE CONNAISSANCE
  • Pages
    • Production
      • CSS
        • Etoiles css Version 1
        • Etoiles avec etiquettes
      • JAVASCRIPT
        • JS du style des étoiles avec etiquettes
        • Copie d'un texte dans le presse papier
        • CheckBox Avec question ouvert
      • HTML TEMPLATE
      • HOMAIR - Post-Stay - Summer 2024
        • css
        • js
      • tracking
      • Projects
      • Formulaire questionnaire
        • Historique de checking
      • CSM
      • Checklist Prod
      • Checklists
        • table_checklist_email
        • table_checklist_questionnaire
      • Clients
    • CSM
      • Tout type de questionnaire
        • NPS
        • Etoile
        • Choix unique
        • Choix multiple
        • Tableaux
        • Ouvert verbatims
        • Ouvert info. perso

CheckBox Avec question ouvert

Dans Alchemer :
image.png
Code JS :
$(document).ready(function () {
// Function to sync checkboxes between origin and target questions
function syncCheckboxes(originSelector, targetSelector) {
// Attach a change event listener to all checkboxes in the origin question
$(`${originSelector} input[type="checkbox"]`).on("change", function () {
// Get the label or aria-label of the changed checkbox
const labelText = $(this).closest("li").find("label").text().trim();
const ariaLabel = $(this).attr("aria-label");

// Find the corresponding checkbox in the target question
const targetCheckbox = $(`${targetSelector} input[type="checkbox"]`).filter(function () {
const targetLabel = $(this).closest("li").find("label").text().trim();
const targetAriaLabel = $(this).attr("aria-label");
return targetLabel === labelText || targetAriaLabel === ariaLabel;
});

// Update the checked state of the target checkbox
if (targetCheckbox.length > 0) {
targetCheckbox.prop("checked", $(this).prop("checked"));
console.log(
`Checkbox with label "${labelText}" ${
$(this).prop("checked") ? "checked" : "unchecked"
} in target question.`
);
} else {
console.warn(
`No matching checkbox found in target question for label "${labelText}".`
);
}
});
}

// Call the function to sync checkboxes
// Pass the selectors for the origin and target question containers
syncCheckboxes("#sgE-90762539-8-59-box ul.sg-list li", "#sgE-90762539-8-93-box ul.sg-list li");
});

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.