Commit 0ac1a3fd by Owen Ryan Ang

XML Generation logic changes to accommodate radiolist changes.

parent 9550d9c8
...@@ -481,7 +481,10 @@ const inputChecklist = (key, validation) => { ...@@ -481,7 +481,10 @@ const inputChecklist = (key, validation) => {
checkbox.name = `checkboxChoices_${key}`; checkbox.name = `checkboxChoices_${key}`;
checkbox.classList.add("checkboxOption"); checkbox.classList.add("checkboxOption");
checkbox.value = item; checkbox.value = item;
if (index == 0) checkbox.setAttribute('id', `${key}`); if (index == 0) {
checkbox.classList.add("checkboxFirst");
checkbox.setAttribute('id', `${key}`);
}
div.appendChild(checkbox); div.appendChild(checkbox);
var label = document.createTextNode(item); var label = document.createTextNode(item);
...@@ -571,8 +574,10 @@ const inputRadiolist = (key, validation) => { ...@@ -571,8 +574,10 @@ const inputRadiolist = (key, validation) => {
radio.name = `radioChoices_${key}`; radio.name = `radioChoices_${key}`;
radio.classList.add("radioOption"); radio.classList.add("radioOption");
radio.value = item; radio.value = item;
if (index == 0) radio.setAttribute('id', `${key}`); if (index == 0) {
radio.classList.add('radioFirst');
radio.setAttribute('id', `${key}`);
}
var label = document.createTextNode(item); var label = document.createTextNode(item);
radioDiv.appendChild(radio); radioDiv.appendChild(radio);
radioDiv.appendChild(label); radioDiv.appendChild(label);
......
...@@ -33,8 +33,9 @@ export async function WriteForm(e,metrics,doctype,section) { ...@@ -33,8 +33,9 @@ export async function WriteForm(e,metrics,doctype,section) {
continue; continue;
} }
// If the first radio button was found // If the first radio button was found
if (fid == 'Radio_List') { if (Nodes[i].classList.contains('radioFirst')) {
const radioButtons = document.getElementsByName('radioChoices'); var key = fid;
const radioButtons = document.getElementsByName(`radioChoices_${key}`);
let selectedValue; let selectedValue;
//check if the value is checked to find the selected value //check if the value is checked to find the selected value
radioButtons.forEach(radio => { radioButtons.forEach(radio => {
...@@ -50,8 +51,9 @@ export async function WriteForm(e,metrics,doctype,section) { ...@@ -50,8 +51,9 @@ export async function WriteForm(e,metrics,doctype,section) {
} }
// If the first checkbox was found // If the first checkbox was found
if (fid == 'Checkbox_List') { if (Nodes[i].classList.contains('checkboxFirst')) {
const checkboxButtons = document.getElementsByName('checkboxChoices'); var key = fid;
const checkboxButtons = document.getElementsByName(`checkboxChoices_${key}`);
let selectedValue = ''; let selectedValue = '';
let isFirstChecked = true; // Variable to track the first checked checkbox let isFirstChecked = true; // Variable to track the first checked checkbox
//check each checkbox if it is checked to find the values. //check each checkbox if it is checked to find the values.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment