function extractAndSetCurrentValues(currentIndex) {
try {
console.log(‘Starting extraction for index:’, currentIndex);
const valuesString = document.getElementById('diagnosis_values').value;
console.log('Values string:', valuesString);
const values = JSON.parse(valuesString);
console.log('Parsed values:', values);
let adjustedIndex = currentIndex - 1;
if (adjustedIndex < 0 || adjustedIndex >= values.length) {
console.error('Invalid index', currentIndex);
return;
}
const currentValues = values[adjustedIndex];
console.log('Current Values:', currentValues);
// Convert array to a simple string to send to Bubble
const currentValuesString = currentValues.join(',');
// Log before sending to Bubble
console.log('Sending to Bubble:', currentValuesString);
// Use the JavaScript to Bubble function to set the value
bubble_fn_getCurrentValues(currentValuesString);
console.log('Successfully set current values in Bubble');
} catch (e) {
console.error('Error extracting current values:', e);
}
}
// Call the function with the dynamic variable ‘currentIndex’
extractAndSetCurrentValues(currentIndex); // Ensure currentIndex is dynamically provided
I’m running this code and getting these values [‘value1’, ‘value2’, ‘value3’]. but I cannot for the like of me get the values out of the javascript and into the page where I can use them. I’ve tried bringing them into a Input box with an ID attribute and then assigning the inputs value to a custom state. I’ve also just tried referencing the input value directly in my repeating group. What you’re looking at now is my 3rd strategy over the last few hours, and i’m tyring to use JavascriptBubble B but bubble won’t let the string through.