I have a few qyuestions with radio boxes to choose form. Once a radio box is clicked it will expand a textbox and display the text fetched from a database.
I have multiple questions and answers all in one content manager database. So I need to be able to reference the field with the answer text using 2 factors, the question and which radio box is chosen.
right now I can obtain only using one parameter (Sorry if my vocab is wrong) and using the below code. And it’s only bringing up the answers for the 6th question (the content manager has answers for all from question 1 and decending to the 6th)
import wixData from 'wix-data';
...
function displayAnswers2(questionName, radioButtonSet, answerBox, answerTxt) {
let rdoSetValue = radioButtonSet.value;
wixData.query("Quiz")
.eq("value", rdoSetValue)
.find()
.then((results) => {
let items = results.items;
let item = items[0];
answerTxt.html = item.answerText;
});
answerBox.expand();
}
// onClick question 1
export function rdbQ1_click(event) {
displayAnswers2( "Kids1", $w('#rdbQ1'), $w('#boxA1'), $w('#txtA1'));
}
//onClick question 2
export function rdbQ2_click(event) {
displayAnswers2("Kids2", $w('#rdbQ2'), $w('#boxA2'), $w('#txtA2'));
}
// onClick question 3
export function rdbQ3_click(event) {
displayAnswers2("Kids3", $w('#rdbQ3'), $w('#boxA3'), $w('#txtA3'));
}
// onClick question 4
export function rdbQ4_click(event) {
displayAnswers2("Kids4", $w('#rdbQ4'), $w('#boxA4'), $w('#txtA4'));
}
// onClick question 5
export function rdbQ5_click(event) {
displayAnswers2("Kids5", $w('#rdbQ5'), $w('#boxA5'), $w('#txtA5'));
}
// onClick question 6
export function rdbQ6_click(event) {
displayAnswers2("Kids6", $w('#rdbQ6'), $w('#boxA6'), $w('#txtA6'));
}
I hope this is not totoally confusing. I don’t have permissiont o share the website, but I could create a smaple of it on a new free wix site