Hi everyone,
I am trying to achieve on a Wix Form, that a given radio button is pre-selected for the user, if they arrive to the Form from a given page.
I am trying to use the session storage (not sure if memory would be better). Here is the code from the source page, where if certain buttons or text is clicked, it leads to the form, while setting the storage:
import { session } from ‘wix-storage’ ;
$w ( ‘#button1’ ). onClick ( function () {
session . setItem ( “formSource” , “service” );
});
$w ( ‘#button23’ ). onClick ( function () {
session . setItem ( “formSource” , “service” );
});
$w ( ‘#text72’ ). onClick ( function () {
session . setItem ( “formSource” , “service” );
});
And here is the code from the Form:
import { session } from ‘wix-storage’ ;
$w . onReady ( function () {
let sourcePage = memory . getItem ( “formSource” );
if ( sourcePage === “service”) { $w ( ‘#radioGroup2’ ). selectedIndex = 0 }
})
There would be some more ‘else if’ statements coming based on other source pages as well.
This doesn’t actually work. What am I doing wrong? Is there a better implementation maybe? When this code is active on the source page, one of the buttons doesn’t actually do anything either, which seems like a bug.
Thanks in advance for any tips and help!