Focal Point
[SOLVED] Javascript to show or hide element based upon selected value in Listbox

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7927043886

November 17, 2017, 10:53 AM
JazBar
[SOLVED] Javascript to show or hide element based upon selected value in Listbox
Hi all,

I'd like to use a JavaScript function that I add to the 'Embedded JavaScript/CSS' section of App Studio.

I have multiple listboxes, all of which have an 'ALL' option. What I want to do is show or hide an element (radio1) depending on whether 'ALL' is selected in listbox3.

I've had a go, but haven't managed to get it to work:

function listbox3_onclick(event) {
var curValue = IbComposer_isSelected('listbox3',['ALL']);
IbComposer_showHtmlElement('radio1',curValue);
}

I believe that once I have the function working correctly, I need to assign a 'JavaScript call' to a 'Selection changed' trigger in 'Tasks and Animations' and assigning the 'Trigger Identifier' to be 'listbox3'?

Any advice would be greatly appreciated.

This message has been edited. Last edited by: FP Mod Chuck,
November 17, 2017, 11:50 AM
MartinY
quote:

function listbox3_onclick(event)
{
var curValue = IbComposer_isSelected('listbox3',['ALL']);
IbComposer_showHtmlElement('radio1',curValue);
}

By the above, it should show radio1 when listbox3 has ALL selected.
So to show or hide I will try it that way

function window_onload() {
   UpdateData();
}
function onInitialUpdate()
{
      IbComposer_showHtmlElement('radio1', 0);
}
function listbox3_onclick(event) {
var eventObject = event ? event : window.event;
var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;
   var curValue = IbComposer_isSelected('listbox3',['ALL']);
 
   if (curValue == 0)
      IbComposer_showHtmlElement('radio1', 1);
   else
      IbComposer_showHtmlElement('radio1', 0);
}



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
November 20, 2017, 06:20 AM
JazBar
Hi MartinY,

That has worked beautifully, thank you very much.

I needed to substitute ['ALL'] with ['_FOC_NULL'] and then, hey presto!

Thank again!
November 20, 2017, 08:11 AM
MartinY
My pleasure

quote:
I needed to substitute ['ALL'] with ['_FOC_NULL']


True depending if you have used the default ALL option from the control or if you have inserted your own value. But yes you may have to change it as you did.

Edit your first post then add [SOLVED] at the beginning of the subject.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007