There are select boxes with names xxx-eavEnumElements, where xxx is a number. These are hard to capture because of how the inputs are generated. We can capture select using a custom code in this case study.
However, the code does not work with checkboxes and radio buttons, so we cannot capture their values.
I created a new custom code to capture the values of the checkbox and radio buttons:
mcfx(function(t) {
t.configure(“onFormCapture”, function(form) {
console.log(‘mcfx form capture’);
var checkboxIds = [‘2467-wfFields’];
for (var idIndex = 0; idIndex < checkboxIds.length; idIndex++) {
var checkboxElement = document.getElementById(checkboxIds[idIndex]);
if (checkboxElement) {
var values = JSON.parse(checkboxElement.value);
console.log(values);
var inputTexts = [];
for (var i = 0; i < values.length; i++) {
var value = values[i];
var checkbox = document.querySelector(‘input[type=”checkbox”][value=”‘ + value + ‘”]’);
if (checkbox) {
var label = checkbox.parentNode;
var text = label.textContent.trim();
inputTexts.push(text);
}
}
var inputText = inputTexts.join(‘, ‘);
var hiddenName = ‘rcfx-custom-name-‘ + checkboxElement.name;
console.log(hiddenName);
var existingInput = form.querySelector(‘input[name=”‘ + hiddenName + ‘”]’);
if (existingInput) {
form.removeChild(existingInput);
}
var inputToAppend = document.createElement(‘input’);
inputToAppend.type = ‘hidden’;
inputToAppend.name = hiddenName;
inputToAppend.value = inputText;
form.appendChild(inputToAppend);
}
}
var radioIds = [‘2451-wfFields’, ‘2455-wfFields’];
for (var idIndex = 0; idIndex < radioIds.length; idIndex++) {
var radioElement = document.getElementById(radioIds[idIndex]);
console.log(radioElement);
if (radioElement) {
//var label = radioElement.parentNode;
//var text = label.textContent.trim();
var value = radioElement.value;
value = value.replace(/”/g, ”); // Remove excess ”
console.log(values);
var inputTexts = [];
var radioButton = document.querySelector(‘input[type=”radio”][value=”‘ + value + ‘”]’);
if (radioButton) {
var label = radioButton.parentNode;
var text = label.textContent.trim();
inputTexts.push(text);
}
var inputText = inputTexts.join(‘, ‘);
var hiddenName = ‘rcfx-custom-name-‘ + radioElement.name;
console.log(hiddenName);
var existingInput = form.querySelector(‘input[name=”‘ + hiddenName + ‘”]’);
if (existingInput) {
form.removeChild(existingInput);
}
var inputToAppend = document.createElement(‘input’);
inputToAppend.type = ‘hidden’;
inputToAppend.name = hiddenName;
inputToAppend.value = text;
form.appendChild(inputToAppend);
}
}
});
});
Values for eavEnumElements for the checkbox and radio button are captured.