Velden verbergen - Elementor formulier

Status
Niet open voor verdere reacties.

vacances2000

Gebruiker
Lid geworden
28 jan 2013
Berichten
121
Beste,
Ik krijg nu het volgende resultaat op basis van de hierna gebruikte HTML code :

RESULTAAT
Mijn postcode begint met :: 10
Postcode 1xxx: christine@w
postcode 2xxx: info@at
postcode 3xxx: ax@
postcode 4xxx: Géén opties
postcode 5xxx: loi@
postcode 6xxx: ex@
postcode 7xxx: Géén opties
postcode 8xxx: fra@
postcode 9xxx: om@
Postcode 10xxx: fn@


HTML CODE
HTML:
<script>

let showThisFieldIf = {
    1: {
        postcode: [1],
    },
    2: {
        postcode: [2],
    },
    3: {
        postcode: [3],
    },
    4: {
        postcode: [4],
    },
    5: {
        postcode: [5],
    },
    6: {
        postcode: [6],
    },
    7: {
        postcode: [7],
    },
    8: {
        postcode: [8],
    },
    9: {
        postcode: [9],
    },
    10: {
        postcode: [10],
    },
}

document.addEventListener('DOMContentLoaded', conditionalFormFieldFunc);
document.addEventListener('DOMContentLoaded',function(){
jQuery(document).on('elementor/popup/show', (event, id, instance) => {
conditionalFormFieldFunc();
});
});

function conditionalFormFieldFunc() {
function testLogic() {
for (const [conditionalInputID, condition] of Object.entries(showThisFieldIf)) {
let conditionalInput = setInputsElemArray(conditionalInputID);
let match = true;
for (const [conditionID, conditionValues] of Object.entries(condition)) {
let inputs = setInputsElemArray(conditionID);
let selectedInputs = [];
inputs.forEach((input, i) => { if (input.checked) { selectedInputs.push(i); } });
if (inputs[0].tagName == 'SELECT') {
selectedInputs.push(inputs[0].selectedIndex);
}
let adjustedConditionValues = conditionValues.map(e => e - 1);
if (!(adjustedConditionValues.every(condition => selectedInputs.indexOf(condition) > -1))) {
match = false;
}
};
if (match) {
conditionalInput.forEach(e => e.closest('.elementor-field-group').style.display = "block")
} else {
conditionalInput.forEach(e => e.closest('.elementor-field-group').style.display = "none")
}
}
}
testLogic();

/* Add event listeners */
for (const [conditionalInputID, condition] of Object.entries(showThisFieldIf)) {
for (const [conditionID, conditionValues] of Object.entries(condition)) {
let inputs = setInputsElemArray(conditionID);
inputs.forEach(input => {
input.addEventListener('input', function () {
testLogic();
})
})
}
}

function setInputsElemArray(ID) {
let selectors = `[name="form_fields[${ID}]"]`;
let inputs = Array.from(document.querySelectorAll(selectors));
if (!inputs.length) {
selectors = `[name="form_fields[${ID}][]"]`;
inputs = Array.from(document.querySelectorAll(selectors));
}
return inputs;
}
};

</script>



Mijn vraag is :
Welk stukje HTML code kun je hieraan toevoegen om postcode 1 tot en met 9 uit het resultaat te verbergen als de klant postcode 10 kiest ?

Doel is dus om het volgende stuk te verbergen en NIET met het formulier mee te sturen :
Postcode 1xxx: christine@w
postcode 2xxx: info@at
postcode 3xxx: ax@
postcode 4xxx: Géén opties
postcode 5xxx: loi@
postcode 6xxx: ex@
postcode 7xxx: Géén opties
postcode 8xxx: fra@
postcode 9xxx: om@

NOG BETER ZOU ZIJN :
een html code waar bij je op basis van de postcode in het ene veld en lijst van keuzes krijgt met verborgen emailadressen in het volgende veld.

Postcode 1234 AZ
-keuze 1
-Keuze 2

Postcode 1562 AG
-keuze 1
-Keuze 2

Dank voor de hulp.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan