Why did my code work before and now suddenly stop?

I don’t understand what happened. my code was working just fine yesterday. Today it just flat decided it doesn’t want to play nice.

The dropdown1 function is greyed out when it wasn’t before. I didn’t modify anything.

$w . onReady ( function () {
$w ( ‘#html2’ ). show ();
$w ( ‘#html3’ ). hide ();
$w ( ‘#html4’ ). hide ();
$w ( ‘#html5’ ). hide ();
$w ( ‘#html6’ ). hide ();
$w ( ‘#html7’ ). hide ();
$w ( ‘#html8’ ). hide ();

$w ( '#table1' ). show (); 
$w ( '#table2' ). hide (); 

})

export function switch1_change ( event ) {
if ( $w ( ‘#switch1’ ). checked === false ){
$w ( ‘#table1’ ). show ();
$w ( ‘#table2’ ). hide ();
}
else if ( $w ( ‘#switch1’ ). checked === true ){
$w ( ‘#table1’ ). hide ();
$w ( ‘#table2’ ). show ();
}

function dropdown1_change ( event ) {
if ( $w ( “#dropdown1” ). value === “Ethereum (ETH)” ){
$w ( ‘#html2’ ). show ();
$w ( ‘#html3’ ). hide ();
$w ( ‘#html4’ ). hide ();
$w ( ‘#html5’ ). hide ();
$w ( ‘#html6’ ). hide ();
$w ( ‘#html7’ ). hide ();
$w ( ‘#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Raven (RVN)” ){
$w ( ‘#html2’ ). hide ();
$w ( ‘#html3’ ). show ();
$w ( ‘#html4’ ). hide ();
$w ( ‘#html5’ ). hide ();
$w ( ‘#html6’ ). hide ();
$w ( ‘#html7’ ). hide ();
$w ( ‘#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Ergo (ERG)” ){
$w ( ‘#html2’ ). hide ();
$w ( ‘#html3’ ). hide ();
$w ( ‘#html4’ ). show ();
$w ( ‘#html5’ ). hide ();
$w ( ‘#html6’ ). hide ();
$w ( ‘#html7’ ). hide ();
$w ( ‘#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Bitcoin Gold (BTG)” ){
$w ( ‘#html2’ ). hide ();
$w ( ‘#html3’ ). hide ();
$w ( ‘#html4’ ). hide ();
$w ( ‘#html5’ ). show ();
$w ( ‘#html6’ ). hide ();
$w ( ‘#html7’ ). hide ();
$w ( ‘#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Eth Classic (ETC)” ){
$w ( ‘#html2’ ). hide ();
$w ( ‘#html3’ ). hide ();
$w ( ‘#html4’ ). hide ();
$w ( ‘#html5’ ). hide ();
$w ( ‘#html6’ ). show ();
$w ( ‘#html7’ ). hide ();
$w ( ‘#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Conflux (CFX)” ){
$w ( ‘#html2’ ). hide ();
$w ( ‘#html3’ ). hide ();
$w ( ‘#html4’ ). hide ();
$w ( ‘#html5’ ). hide ();
$w ( ‘#html6’ ). hide ();
$w ( ‘#html7’ ). show ();
$w ( ‘#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Cortex (CTXC)” ){
$w ( ‘#html2’ ). hide ();
$w ( ‘#html3’ ). hide ();
$w ( ‘#html4’ ). hide ();
$w ( ‘#html5’ ). hide ();
$w ( ‘#html6’ ). hide ();
$w ( ‘#html7’ ). hide ();
$w ( ‘#html8’ ). show ();
}
}
}

$w.onReady(function () {
    $w('#html2').show();
    $w('#html3').hide();
    $w('#html4').hide();
    $w('#html5').hide();
    $w('#html6').hide();
    $w('#html7').hide();
    $w('#html8').hide();
    //--------------------
    $w('#table1').show();
    $w('#table2').hide();
});

export function switch1_change(event) {
  if($w('#switch1').checked === false){
    $w('#table1').show();
    $w('#table2').hide();
  }
  else if($w('#switch1').checked === true){
    $w('#table1').hide();
    $w('#table2').show();
  }
}

function dropdown1_change(event) {
  if($w("#dropdown1").value === "Ethereum (ETH)"){
    $w('#html2').show();
    $w('#html3').hide();
    $w('#html4').hide();
    $w('#html5').hide();
    $w('#html6').hide();
    $w('#html7').hide();
    $w('#html8').hide();
  }   
  else if($w("#dropdown1").value === "Raven (RVN)"){
    $w('#html2').hide();
    $w('#html3').show();
    $w('#html4').hide();
    $w('#html5').hide();
    $w('#html6').hide();
    $w('#html7').hide();
    $w('#html8').hide();
  }
  else if($w("#dropdown1").value === "Ergo (ERG)"){
    $w('#html2').hide();
    $w('#html3').hide();
    $w('#html4').show();
    $w('#html5').hide();
    $w('#html6').hide();
    $w('#html7').hide();
    $w('#html8').hide();
  }
  
  //better coding .....
  else if($w("#dropdown1").value === "Bitcoin Gold (BTG)"){
    $w('#html2,#html3,#html4,#html6,#html7,#html8').hide('fade');
    $w('#html5').show('fade');
  }
  else if($w("#dropdown1").value === "Eth Classic (ETC)"){
    $w('#html2,#html3,#html4,#html5,#html7,#html8').hide('fade');
    $w('#html6').show('fade');
  }
  else if($w("#dropdown1").value === "Conflux (CFX)"){
    $w('#html2,#html3,#html4,#html5,#html6,#html8').hide('fade');
    $w('#html7').show('fade');
  }
  else if($w("#dropdown1").value === "Cortex (CTXC)"){
    $w('#html2,#html3,#html4,#html5,#html6,#html7').hide('fade');
    $w('#html8').show('fade');
  }
}

EDIT:
Make sure → you did not lost connection between CODE & PROPERTIES-PANEL!

How do I check that and how do I reconnect?

Just do not use EXPORT FUNCTIONS in future and try to learn a new CODING-STYLE…

$w.onReady(()=>{
    $w('#html2').show();
    $w('#html3').hide();
    $w('#html4').hide();
    $w('#html5').hide();
    $w('#html6').hide();
    $w('#html7').hide();
    $w('#html8').hide();
    //--------------------
    $w('#table1').show();
    $w('#table2').hide();


$w('#switch1').onChange(()=>{
  if($w('#switch1').checked === false){
    $w('#table1').show();
    $w('#table2').hide();
  }
  else if($w('#switch1').checked === true){
    $w('#table1').hide();
    $w('#table2').show();
  }
});

$w('#dropdown1').onChange(()=>{
  if($w("#dropdown1").value === "Ethereum (ETH)"){
    $w('#html2').show();
    $w('#html3').hide();
    $w('#html4').hide();
    $w('#html5').hide();
    $w('#html6').hide();
    $w('#html7').hide();
    $w('#html8').hide();
  }   
  else if($w("#dropdown1").value === "Raven (RVN)"){
    $w('#html2').hide();
    $w('#html3').show();
    $w('#html4').hide();
    $w('#html5').hide();
    $w('#html6').hide();
    $w('#html7').hide();
    $w('#html8').hide();
  }
  else if($w("#dropdown1").value === "Ergo (ERG)"){
    $w('#html2').hide();
    $w('#html3').hide();
    $w('#html4').show();
    $w('#html5').hide();
    $w('#html6').hide();
    $w('#html7').hide();
    $w('#html8').hide();
  }
  
  //better coding .....
  else if($w("#dropdown1").value === "Bitcoin Gold (BTG)"){
    $w('#html2,#html3,#html4,#html6,#html7,#html8').hide('fade');
    $w('#html5').show('fade');
  }
  else if($w("#dropdown1").value === "Eth Classic (ETC)"){
    $w('#html2,#html3,#html4,#html5,#html7,#html8').hide('fade');
    $w('#html6').show('fade');
  }
  else if($w("#dropdown1").value === "Conflux (CFX)"){
    $w('#html2,#html3,#html4,#html5,#html6,#html8').hide('fade');
    $w('#html7').show('fade');
  }
  else if($w("#dropdown1").value === "Cortex (CTXC)"){
    $w('#html2,#html3,#html4,#html5,#html6,#html7').hide('fade');
    $w('#html8').show('fade');
  });
});

Coding this way → any connections to the property-panel needed!

Pay attention → code was edited!

I’ve implemented your coding style. I didn’t realize you could add more than one argument to a line.

@russian-dima Thank you for that!

@james97196
Just COPY and PASTE it! —> Test it!

Does it work now?

If you still want to do it your own OLD-CODING-STYLE, then navigate to the properties-panel. Delete the existing connection and create a new one.

Example → properties-panel of a button…

EDIT: Try always to CODE the most → COMPACT-WAY ←

instead of using this one…

else if($w("#dropdown1").value === "Raven (RVN)"){
    $w('#html2').hide();
    $w('#html3').show();
    $w('#html4').hide();
    $w('#html5').hide();
    $w('#html6').hide();
    $w('#html7').hide();
    $w('#html8').hide();
  }

better use this one…

else if($w("#dropdown1").value === "Bitcoin Gold (BTG)"){
    $w('#html2,#html3,#html4,#html6,#html7,#html8').hide('fade');
    $w('#html5').show('fade');
  }

…or even create a “LOOP”-function for it, what would be the best way of how to do it…

for (let index = 0; index < array.length; index++) {
      const element = array[index];
      // your code here.......
  }
@Velo-Ninja I copied and pasted. There were a couple syntax errors to correct, but not a big deal. It's still not working though.

$w.onReady(function () {
    $w('#html2').show();
    $w('#html3,#html4,#html5,#html6,#html7,#html8').hide();
    
    $w('#table1').show();
    $w('#table2').hide();
})

$w('#switch1').onChange(()=>{
  if($w('#switch1').checked === false){
    $w('#table1').show();
    $w('#table2').hide();
  }
  else if($w('#switch1').checked === true){
    $w('#table1').hide();
    $w('#table2').show();
  }
})

$w('#dropdown1').onChange(()=>{
    
    if($w("#dropdown1").value === "Ethereum (ETH)"){
        $w('#html3,#html4,#html5,#html6,#html7,#html8').hide('fade');
        $w('#html2').show('fade');
  }
    else if($w("#dropdown1").value === "Raven (RVN)"){
        $w('#html2,#html4,#html5,#html6,#html7,#html8').hide('fade');
        $w('#html3').show('fade');
  }
    else if($w("#dropdown1").value === "Ergo (ERG)"){
        $w('#html2,#html3,#html5,#html6,#html7,#html8').hide('fade');
        $w('#html4').show('fade');
  }
    else if($w("#dropdown1").value === "Bitcoin Gold (BTG)"){
        $w('#html2,#html3,#html4,#html6,#html7,#html8').hide('fade');
        $w('#html5').show('fade');
  }
    else if($w("#dropdown1").value === "Eth Classic (ETC)"){
        $w('#html2,#html3,#html4,#html5,#html7,#html8').hide('fade');
        $w('#html6').show('fade');
  }
    else if($w("#dropdown1").value === "Conflux (CFX)"){
        $w('#html2,#html3,#html4,#html5,#html6,#html8').hide('fade');
        $w('#html7').show('fade');
  }
    else if($w("#dropdown1").value === "Cortex (CTXC)"){
        $w('#html2,#html3,#html4,#html5,#html6,#html7').hide('fade');
        $w('#html8').show('fade');
  }
})

@james97196
Ok! Next step of debugging…

$w('#dropdown1').onChange(()=>{console.log("DropDown1 changed!!!")
    if($w("#dropdown1").value === "Ethereum (ETH)"){console.log("if-1");
        $w('#html3,#html4,#html5,#html6,#html7,#html8').hide('fade');
        $w('#html2').show('fade');
  }
    else if($w("#dropdown1").value === "Raven (RVN)"){console.log(.........);
        $w('#html2,#html4,#html5,#html6,#html7,#html8').hide('fade');
        $w('#html3').show('fade');
  }
    else if($w("#dropdown1").value === "Ergo (ERG)"){console.log(.........);
        $w('#html2,#html3,#html5,#html6,#html7,#html8').hide('fade');
        $w('#html4').show('fade');
  }
    else if($w("#dropdown1").value === "Bitcoin Gold (BTG)"){console.log(.........);
        $w('#html2,#html3,#html4,#html6,#html7,#html8').hide('fade');
        $w('#html5').show('fade');
  }
    else if($w("#dropdown1").value === "Eth Classic (ETC)"){console.log(.........);
        $w('#html2,#html3,#html4,#html5,#html7,#html8').hide('fade');
        $w('#html6').show('fade');
  }
    else if($w("#dropdown1").value === "Conflux (CFX)"){console.log(.........);
        $w('#html2,#html3,#html4,#html5,#html6,#html8').hide('fade');
        $w('#html7').show('fade');
  }
    else if($w("#dropdown1").value === "Cortex (CTXC)"){console.log(.........);
        $w('#html2,#html3,#html4,#html5,#html6,#html7').hide('fade');
        $w('#html8').show('fade');
  }
})

What is different now?

Exactly we will now use some CONSOLE-LOGS to locate the issue…
Do you get the any message in the CONSOLE?

If so —> your button works and the issue is located somewhere else.
If not → you have a button-event-problem.

Put some more LOGICAL console-logs into the shown code-part by your own…

Test your code and locate your bug!

EDIT: Which CONSOLE-LOGs could also be interessting for you ?
—> dropdown-values?

@james97196

Also this one can be better…

if($w('#switch1').checked===false){......

Use this one instead…

if($w('#switch1').checked){console.log("Checked !!!");
else {console.log("Unchecked !!!");}

→ === ← not neccessary in this situation.
As already mentioned → always try to code → COMPACT (SYSTEMATIC, FLEXIBLE & CLEAR)!

The loop is a bit advanced for me. I’m very new to JS. I’ve only had experience in basic and it’s only for HVAC application. I don’t even understand the syntax fully yet.

It’s okay! Some month of practice and you will be more familiar with the JS-Syntax.

Your biggest challenges will be surely…

  • onReady()
  • async-await
  • .then() -methods/commands

Pay always attention on them in your JS-Syntax.

And do never forget —> CONSOLE <— is your —> BEST-FRIEND!

@russian-dima HAHAHA! Yeah, that cat shows about how I feel right now.

@james97196 :stuck_out_tongue_winking_eye:

$w . onReady (()=> {
$w ( ‘#html2’ ). show ();
$w ( ‘#html3,#html3,#html4,#html5,#html6,#html7,#html8’ ). hide ();

$w ( '#table1' ). show (); 
$w ( '#table2' ). hide (); 

$w ( ‘#switch1’ ). onChange (()=>{
if ( $w ( ‘#switch1’ ). checked === false ){
$w ( ‘#table1’ ). show ();
$w ( ‘#table2’ ). hide ();
}
else if ( $w ( ‘#switch1’ ). checked === true ){
$w ( ‘#table1’ ). hide ();
$w ( ‘#table2’ ). show ();
}

$w ( ‘#dropdown1’ ). onChange (()=>{
if ( $w ( “#dropdown1” ). value === “Ethereum (ETH)” ){
$w ( ‘#html2’ ). show ();
$w ( ‘#html3,#html4,#html5,#html6,#html7,#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Raven (RVN)” ){
$w ( ‘#html3’ ). show ();
$w ( ‘#html2,#html4,#html5,#html6,#html7,#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Ergo (ERG)” ){
$w ( ‘#html4’ ). show ();
$w ( ‘#html2,#html3,#html5,#html6,#html7,#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Bitcoin Gold (BTG)” ){
$w ( ‘#html5’ ). show ();
$w ( ‘#html2,#html3,#html4,#html6,#html7,#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Eth Classic (ETC)” ){
$w ( ‘#html6’ ). show ();
$w ( ‘#html2,#html3,#html4,#html5,#html7,#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Conflux (CFX)” ){
$w ( ‘#html7’ ). show ();
$w ( ‘#html2,#html3,#html4,#html5,#html6,#html8’ ). hide ();
}
else if ( $w ( “#dropdown1” ). value === “Cortex (CTXC)” ){
$w ( ‘#html8’ ). show ();
$w ( ‘#html2,#html3,#html4,#html5,#html6,#html7’ ). hide ();
}
})
})
})

@russian-dima We got it! I learned a lot on this issue! Thank you so much, Velo-Ninja!

@james97196 Do not forget to like it, if you really liked it :wink::v:

One last tip—> try always to use a code-block, to show your code. It will be shown in a nicely formated style and will make the code better readable.