Is there basic or super simple code for if and else statements that show or hide based on the text present?

If you want to go with the option above them you can do it in a simple way like this.

First Page.

  • Dataset with text fields for saving the radio button value and the dropdown value into the dataset when the user clicks on the button. Dataset is set to Write only.

  • Dataset fields are simply called Radio Button (radiobutton) and Dropdown (dropdown) - Field Name (field key)

  • Button is connected to the dataset so that you can submit the answers from the user inputs and the success or failed messages are added from that submit option too.

  • The button is also set as linked to the next page after the form has been submitted and is successful.

  • The user inputs are set as not required, so untick the settings if you have it set as required.

No code used on this first page

Second Page.

  • Same setup as on previous example, just with no user inputs on page as now not needed.

  • Just the two text boxes now on the page and they are not connected to the dataset.

  • Same dataset used as on the first page, however this time the dataset is set to Read Only.

Code Used.

$w.onReady(() => {
$w("#myDataset").onReady(() => {
const item = $w("#myDataset").getCurrentItem();
if (!item.dropdown) {
$w("#text1").collapse();
if (!item.radiobutton) {
$w("#text2").collapse();
}
}
});
});

So if no values are chosen then the second page would have no text boxes showing.


Blank page here, blink and you miss it!

If values are chosen and the dataset has values in the required dataset fields, then the text boxes are shown.

Again you can do this with the onViewportEnter event handler function, you will just need to change your code to suit again, so that the text boxes or what ever you are using are not shown until the user gets to the viewport area of where you want.

Try something like this.

$w.onReady( () => {
$w("#myDataset").onReady(() => {
});
});

export function someElement_onViewportEnter() {
const item = $w("#myDataset").getCurrentItem();
if (!item.dropdown) {
$w("#text1").collapse();
if (!item.radiobutton) {
$w("#text2").collapse();
}
}
}

Thank you so much. I will give it a shot and let you know as soon as I can. Once again, Thanks!

Hi Gos,
I tried everything you’ve given me and I’ve been working on it for hours but still no success. Do I need the Wix storage if I send the value to #dropbox4 through data collection? Because the value does get sent with just data collections but nothing happens to the text box. I’ve tried everything and I even made a new site to build all of the things you made to show me, and I still have no success. All I need is for a text box to show or hide based on the value of dropbox on another page. Let me know if there is anything else that I can try. It would be great if you could come on to my site and see the code and correct it, but thank you again for all the help you’ve given and thank you for all of your time.
Thanks,
Kalyan

@kalyankaramsetty
Don’t worry about it all, give it a day and you will look at it and it will all click together for you, honestly!

Post up at the bottom of this post (so that it doesn’t get muddled up with other parts), what code you have got setup on your pages as of now along with any screenshots etc.

If you go with the second code option that we talked about (the one with this in the code, if (!item.dropdown) { and if (!item.radiobutton) {), then no you do not need the Wix Storage import line at the top of your code as you are not using it.