Fields in Input Forms XML | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
akshaaga
akshaagaAccepted solution
Employee
Aug 14, 2023 5:50 AM UTC

@alnavarg ,

You can achieve this behavior by using JavaScript to dynamically enable or disable the input fields based on the user's selection. Try to use event listeners to detect changes in the checkboxes and then manipulate the input fields accordingly.

Here's an example :

1. Create your input form with three fields (Field A, Field B, Field C) and a "None" checkbox.

 

2. Add JavaScript to your form's HTML to handle the dynamic behavior:

const checkboxA = document.getElementById('checkboxA');
const checkboxB = document.getElementById('checkboxB');
const checkboxC = document.getElementById('checkboxC');
const fieldA = document.getElementById('fieldA');
const fieldB = document.getElementById('fieldB');
const fieldC = document.getElementById('fieldC');


checkboxA.addEventListener('change', () => {
fieldA.disabled = !checkboxA.checked;
});

checkboxB.addEventListener('change', () => {
fieldB.disabled = !checkboxB.checked;
});

checkboxC.addEventListener('change', () => {
fieldC.disabled = !checkboxC.checked;
});

// Add event listener to "None" checkbox
const noneCheckbox = document.getElementById('noneCheckbox');
noneCheckbox.addEventListener('change', () => {
if (noneCheckbox.checked) {
checkboxA.checked = false;
checkboxB.checked = false;
checkboxC.checked = false;
fieldA.disabled = true;
fieldB.disabled = true;
fieldC.disabled = true;
}
});


3. Adjust the IDs and classes in the JavaScript code to match your HTML structure.

4. Ensure that you place this JavaScript code within the HTML of your Adobe Campaign input form.

3 replies

_Manoj_Kumar_
New Participant
Aug 24, 2023 12:11 AM UTC

Hello @alnavarg 

 

Do you still have any questions on this? The correct answer is regarding the web form on WebApp, but the question in for the input form.

Translate
     Manoj     Find me on LinkedIn
akshaaga
akshaagaAccepted solution
Employee
Aug 14, 2023 5:50 AM UTC

@alnavarg ,

You can achieve this behavior by using JavaScript to dynamically enable or disable the input fields based on the user's selection. Try to use event listeners to detect changes in the checkboxes and then manipulate the input fields accordingly.

Here's an example :

1. Create your input form with three fields (Field A, Field B, Field C) and a "None" checkbox.

 

2. Add JavaScript to your form's HTML to handle the dynamic behavior:

const checkboxA = document.getElementById('checkboxA');
const checkboxB = document.getElementById('checkboxB');
const checkboxC = document.getElementById('checkboxC');
const fieldA = document.getElementById('fieldA');
const fieldB = document.getElementById('fieldB');
const fieldC = document.getElementById('fieldC');


checkboxA.addEventListener('change', () => {
fieldA.disabled = !checkboxA.checked;
});

checkboxB.addEventListener('change', () => {
fieldB.disabled = !checkboxB.checked;
});

checkboxC.addEventListener('change', () => {
fieldC.disabled = !checkboxC.checked;
});

// Add event listener to "None" checkbox
const noneCheckbox = document.getElementById('noneCheckbox');
noneCheckbox.addEventListener('change', () => {
if (noneCheckbox.checked) {
checkboxA.checked = false;
checkboxB.checked = false;
checkboxC.checked = false;
fieldA.disabled = true;
fieldB.disabled = true;
fieldC.disabled = true;
}
});


3. Adjust the IDs and classes in the JavaScript code to match your HTML structure.

4. Ensure that you place this JavaScript code within the HTML of your Adobe Campaign input form.

Translate
_Manoj_Kumar_
New Participant
Aug 14, 2023 4:48 AM UTC

Hello @alnavarg 

 

Can you show some visual representation of how it should work?

 

Are there three checkboxes and three input fields?

Translate
     Manoj     Find me on LinkedIn