Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only. Moving forward, myibi is our community platform to learn, share, and collaborate. We have the same Focal Point forum categories in myibi, so you can continue to have all new conversations there. If you need access to myibi, contact us at myibi@ibi.com and provide your corporate email address, company, and name.


Connect to myibi
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Javascript to show or hide element based upon selected value in Listbox

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Javascript to show or hide element based upon selected value in Listbox
 Login/Join
 
Member
posted
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,
 
Posts: 11 | Location: United Kingdom | Registered: September 07, 2010Report This Post
Virtuoso
posted Hide Post
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
 
Posts: 2410 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Member
posted Hide Post
Hi MartinY,

That has worked beautifully, thank you very much.

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

Thank again!
 
Posts: 11 | Location: United Kingdom | Registered: September 07, 2010Report This Post
Virtuoso
posted Hide Post
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
 
Posts: 2410 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Javascript to show or hide element based upon selected value in Listbox

Copyright © 1996-2020 Information Builders