RadioButton
Location
• Hamilton
• Burlington
when I click or choose Hamilton the page goes to the hamilton page
How to use RadioButton to redirect to a site page?
DropDown
Location
• Hamilton
• Burlington
when I click or choose Hamilton the page goes to the hamilton page
//import wix-location here on the very top of your code first!!!
$w.onReady(()=>{
$w('#myRadiobuttonGroup').onChange((event)=>{
console.log("Event: ", event);
console.log("Target: ", event.target);
console.log("ID: ", event.target.id);
let selectedValue =$w('#myRadiobuttonGroup').value;
console.log("Selected RB-Value: ", selectedValue);
if(selectedValue==="xxx") {
wixLocation.to("https://www.google.com");
}
});
});
Something like this.
Here is an example I use with a submit button for choice, and also some logic if they don’t make a selection, then a statebox(Statebox8) un-hides to remind them to click one.
import wixLocation from ‘wix-location’ ;
import { session } from ‘wix-storage’ ;
import wixWindow from ‘wix-window’ ;
$w . onReady ((()=>{
$w ( ‘#radioGroup2’ ). onChange (()=>{
const selValue = $w ( “#radioGroup2” ). value ; console . log ( "Selected.Value: " , selValue );
});
$w ( ‘#submitWorry’ ). onClick (( event ) => {
submitWorry_click ( event );
})
})
)
export async function submitWorry_click ( event ) {
if ( $w ( “#radioGroup2” ). value === “CyberAttack” )
{ wixLocation . to ( ‘/URLHERE’ );}
else if ( $w ( “#radioGroup2” ). value === “BusinessDisruption” ) {
wixLocation . to ( ‘/URLHERE’ );}
else if ( $w ( “#radioGroup2” ). value == “FinancialLoss” ) {
wixLocation . to ( ‘/URLHERE’ );}
else if ( $w ( “#radioGroup2” ). value === “StolenSocials” ) {
wixLocation . to ( ‘/URLHERE’ );}
else if ( $w ( “#radioGroup2” ). value === “Insurance” ) {
wixLocation . to ( ‘/URLHERE’ );}
else if ( $w ( “#radioGroup2” ). value === “Scammed” ) {
wixLocation . to ( ‘/URLHERE’ );}
else ( $w ( ‘#statebox8’ ). show ())
}