show() & hide() code not working

Hi everybody,
I’m only a beginner at wix coding and I wrote the following code, but it’s not working as coded.

$w . onReady ( function () {
let language = wixWindow . multilingual . currentLanguage
if ( language === “nl” ) {
$w ( ‘#form1’ ). show ()
$w ( ‘#form2’ ). hide ()
}
else if ( language === “fr” )
{
$w ( ‘#form1’ ). hide ()
$w ( ‘#form2’ ). show ()
}
});

On startup with the language “nl”, form1 shows up and not form2 as it should be. Then when changing the language to “fr” there are no forms to be seen any more.
When going back to “nl” no forms are showing up any more, not even the one that showed up at startup…

Can anyone help me and put me on the right track please.
Maybe I got something wrong or are forgetting a part of code?

Thanks for your help

Try to add console.log():

//...code...
let language = wixWindow.multilingual.currentLanguage;
console.log('language', language);
//....code...

And see what it logs to the console., maybe it will give you a clue what the problem is.

Always get the right language when changing from one language to another, but code still not working…

I don’t see any problem with your code.
Maybe someone else will have an idea.

Could it be a problem in Wix itself?

It always can, but in this case I doubt it.
Can you post the url of your live site (leave the console.log there) and I may be able to take a look.

Hi,
Do you mean the link to the published site?

That what I meant (But I’m going to be offline until Wednesday)

Hi,
I haven’t published it as it doesn’t work. I’m still trying to get it working in preview mode.
Even tried it by writing the code in a separate function and it still doesn’t work.

Create a page for development only, set it so search engines will not index it, publish and test, because preview mode doesn’t always reflect the live site behavior(especially when it comes to wixWindow methods).

If you use Wix Forms there are 2 options for ID, try to hide and show the second option (see screenshot)

And also if it comes to backend-codings, also different behaviour.
I also ALWAYS check the LIVE-SITE aswell.

Hi Wixproisrael,

Tried that too and still not working.
There’s a problem with wix forms using multilingual.
I started with 2 forms on the same page. 1 for the “nl” language and one for the “fr” language. So as it didn’t work out, I thought that the problem was 2 forms on 1 page. So I changed it again to 1 form to test and even then it doesn’t work.

So say you have a page with a form named “#form1
Say you are in the multilingual “nl” (editor mode).
Then the value of “#form1” should be visible
Until there no problem.

When switching to the multilingual “fr” (editor mode)
Then the value of “#form1” should be hidden
And there’s the problem…

When setting the value of a form to “Hidden”, the value stays the same in both languages. So visible in multilingual “nl” means also visible in multilingual “fr”. Hidden in multilingual “nl” means also hidden in multilingual “fr”…
Even with code it doesn’t work…

So the main problem is that a form’s “hidden” value isn’t changeable when changing languages. By that I mean that it’s not like the translating possibility of a textbox. When changing from multilingual “nl” to “fr” the text you translated in the corresponding language is shown.