I am trying to assign a field value from a database to a radioGroup inside a repeater, and have the selected radioGroup value submitting to a writable form database.
Right now I am executing the submit in code using wixdata.insert, I have also tried with .save(). In every event a new entry is created, but the entries come up blank…even though a radio button was selected.
Right now I am setting the options of radioGroup1 to be the text #planInternet.
I have #planInternet connected to the database that is feeding the repeater…and so it is that value that I want to submit.
If I connect the submit button not using code…I get an entry equivalent to whatever is in the text box inside the editor. In this instance…“Plan Internet” is submitted.
Done using code…nothing gets submitted, but a new entry is successfully made.
I am not sure if I am using setFieldValue correctly…but I believe it hold the key to getting the database value over and into the submission dataset.
$item(‘#datasetSubmit’).setFieldValue(‘tvInternet’,$w(‘#radioGroup1’).value);
Pic and current code below…
import wixData from ‘wix-data’;
//TV Internet Repeater Radio Group//
$w.onReady( function () {
$w("#repeater1").onItemReady( (itemData, index) => {
$w("#radioGroup1").options = [
{“label”: “”, “value”: $w(“#planInternet”).text},
];
$w(“#radioGroup1”).onClick( (event, $w) => {
resetRadioButtons();
let $item = $w.at(event.context)
$item(“#radioGroup1”).selectedIndex = 0;
$item(‘#datasetSubmit’).setFieldValue(‘tvInternet’,$w(‘#radioGroup1’).value);
} );
})
})
export function resetRadioButtons () {
$w(‘#radioGroup1’).selectedIndex = undefined;
}
$w.onReady( function () {
let tvinternet
let electric;
let insurance;
let movers;
let security;
});
export function submit_click(event, $w) {
let toInsert = {
‘tvInternet’ : $w(‘#radioGroup1’).value,
‘electric’ : $w(‘#radioGroup2’).value,
‘insurance’ : $w(‘#radioGroup3’).value,
‘movers’ : $w(‘#radioGroup4’).value,
‘security’ : $w(‘#radioGroup5’).value,
};
wixData.insert(“UtilitiesSubmission”, toInsert)
resetForm();
}
function resetForm() {
$w(‘#radioGroup1’).value = ‘’
}