Haim
Posts: 0
Joined: Wed Sep 05, 2012 9:15 am

How to assign Event & Action for "select menu" component

I think it's close... but let me be more explicit:

I already have a dropdown menu with two choices: "A" and "B"

By default, "A" is selected. When I update the menu to "B", I then set a localStorage variable to "B" so I know it for the future. This all works just fine...

Then I move on to another screen and the new value of "B" is properly stored in the local storage.

Later on, I come back into the settings screen where I have this dropdown menu. Since my localStorage is set to "B", I want the menu to appear initialized to "B" and not to "A" (which was selected when I defined the menu).

When I do a setProperty on screen load for this (which should set "B" to be selected), it doesn't update the menu. Is a refresh required? If that's the case, when do it? I've defined a JS that does the refresh after the setProperty call in Tiggzi... but it's not updated.

Comments?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to assign Event & Action for "select menu" component

http://stackoverflow.com/questions/18...

Every time after page load you have to clear the menu and add new elements depending on the content of its variable.
Don't forget refresh.

Chris McKenna6917608
Posts: 0
Joined: Sat Jun 07, 2014 2:12 am

How to assign Event & Action for "select menu" component

I am new to javascript. I have similar need to this topic I have a select, that I want to set Displlay to table if the value in the select = Yes.

I have a grid that i setup called Grid6, that if the value of the select is No and by default .. then I don't want it to display. So in the grid.. I un check the Visibility check box. This actually set the display not the visibility style attr.

Anyway, here is the code I hacked up and got to work, thanks to the comments in this stream.

--------------------------------------------------------------------------------

var myVar = $(this).val();

if (myVar == "Yes"){

document.getElementById('GuestSurvey_Grid6').style.display="table";

} else {

document.getElementById('GuestSurvey_Grid6').style.display="none";

}

-----------------------------------------------------------------------

However, i had to look up via inspect element on chrome and find that they id was GuestSurvey (the page name) then the component Name. Is there a way i could have just referenced the component by name?

Thanks
Chris

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to assign Event & Action for "select menu" component

Hi Chris.

Please modify your current code with following one:

precode

var myVar = $(this).val();

if (myVar == "Yes"){
//Where "GuestSurvey_Grid6" is your component name.
Apperyio("GuestSurvey_Grid6").show();
}
else{
//Where "GuestSurvey_Grid6" is your component name.
Apperyio("GuestSurvey_Grid6").hide();
}

/code/pre

Note: in this code "GuestSurvey_Grid6" is your table component name. Please replace it with your one.

That's all.

Regards.

Chris McKenna6917608
Posts: 0
Joined: Sat Jun 07, 2014 2:12 am

How to assign Event & Action for "select menu" component

Thank you !.. that worked perfectly!

Return to “Issues”