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.
Best answer by akshaaga

@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
Community Advisor
Community Advisor
August 14, 2023

Hello @alnavarg 

 

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

 

Are there three checkboxes and three input fields?

Manoj  | https://themartech.pro
akshaaga
Adobe Employee
akshaagaAdobe EmployeeAccepted solution
Adobe Employee
August 14, 2023

@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.

Manoj_Kumar
Community Advisor
Community Advisor
August 24, 2023

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.

Manoj  | https://themartech.pro