Having a dog of a time trying to get two code blocks to work together. Doing the first one (as shown) works fine but when I do the second one, it just doesn't work, and I'm sure I have y end of code block thingy's wrong. Can you explain when and when not to put the end of code semicolon and how many times?
For example, I've see }); and sometimes I've seen }) and sometimes I've seen them twice and sometimes only once.
Here's what I have... (using one or the other independently works, but never both.)
$w.onReady(function () { //TODO: write your page related code here... // This is the CURRENTLY IN OR VETERAN STATUS line $w.onReady(function(){ $w("#vectorImage14").hide() $w("#dropdown5").hide() $w("#text79").hide() // This is the ANNUAL OR LIEFTIME line $w.onReady(function(){ $w("#dropdown6").hide() }) }); //next function: ITEM1 2 3 make these three items hidden above appear when radiobutton3 === YES is selected $w("#radioGroup3").onChange(function() { if($w("#radioGroup3").value === "responseyes") $w("#vectorImage14").show() $w("#text79").show() $w("#dropdown5").show() }) });
//next function: these two items SHOW when LIFETIME radio button is pressed
$sw("#radioGroup6") onChange(function() }
$sw("#vectorimage18").show()
$sw("#dropdown7").show()
}};
});
Hi, H G R.
In addition to what givemeawhisky said ...
In the following comment:
//next function: ITEM1 2 3 make these three items hidden above appear when radiobutton3
if you do, indeed, mean "hidden", then shouldn't "show()" in each of the three/3 following lines be replaced with "hide()":
$w("#vectorImage14").show() $w("#text79").show() $w("#dropdown5").show()
?
Also, I believe that you intended that the above three/3 lines should be surrounded by curly braces ( { and } ) since I believe you meant that they should all be run only if the condition evaluates to true.
I also recommend that you replace each generically named control with a mnemonic name (makes it much easier to read, grok and maintain your code).
You need the semi colons in your code, as shown in the API reference for the show and hide functions and in code examples too.
https://www.wix.com/corvid/reference/$w.HiddenMixin.html
https://support.wix.com/en/article/corvid-tutorial-hiding-an-element-on-certain-pages
Some will say that they are optional and you don't need to use them, however it is always best to do so when they are needed, have a read of these for example.
https://code.likeagirl.io/why-the-heck-do-i-need-to-use-semi-colons-in-javascript-4f8712c82329
https://flaviocopes.com/javascript-automatic-semicolon-insertion/
As for the curly brackets {} and parentheses (), well you need to make sure that you have matching pairs of them all, so basically you must have equal numbers of open { and closed } curly brackets and open ( and closed ) parentheses.
Also, you should only have the one onReady page function on your page.