Vorbly <Code>

CODING MADE EASY WITH VORBLY

WIX CODE COLLAPSE OR EXPAND FORM OPTIONS

Need to customize your user forms and menus? This tutorial will show you how to use a Switch button to collapse (or expand) form options or menus. You will be able to streamline your online forms and show only relevant options. We will provide you with the webpage elements and sample codes required to implement this feature.

THE DEMO

1/2

THE ELEMENTS

The Page

Switch Button: #switch1

​​

User Inputs:

  • Email Field ID: #email

  • Radio Buttons (Interests): #radioGroup1

  • Radio Buttons (Frequency)#radioGroup2

Submit Button: #submit

THE CODE

Page Code

export function switch1_change(event) {

    let option = $w("#switch1").checked;

    if (option === false){

        $w("#group1").collapse();

    } else {

        $w("#group1").expand();

    }

}

COMMENTS

I'm a paragraph. Click here to add your own text and edit me. It's easy.

No comments. Be the first to leave a comment.

Thanks for this. I am hoping to be able to do this with an already preselected checkbox. Basically, a user will be signed into the website, and admin will then select whether they should see a certain strip or not (via the database), then the strip should either appear or not. Could you tell me how i would modify the code to achieve this?

Nathan

Nov 08, 2018

0

Hi Nathan,

Thanks for reaching out to us here and on Facebook. Would you be able to provide more details on what you are trying to achieve?

Andrew (Vorbly)

Nov 09, 2018

1

WEB DESIGN & DEVELOPMENT SOLUTIONS

GET PROFESSIONAL HELP