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.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Problems with multiselect listbox in HTML

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Problems with multiselect listbox in HTML
 Login/Join
 
Guru
posted
Has anybody found out how to handle the listbox with multiselect?
Assume the listbox1_onclick function is as follows:
alert(this.listbox1.options.selectedIndex);

If I click on eg. row no 2 in a listbox it says 0 (wrong) at first attempt, but on the second attempt it says 1 (correct).

Any help is appreciated.


WebFOCUS DS 8.0.06/08 DS/AS
WebFOCUS RS 8.0.08 (Linux/IBM i)
WebFOCUS Client 8.0.06 (Linux)
 
Posts: 319 | Location: Stockholm, Sweden | Registered: February 04, 2004Report This Post
Guru
posted Hide Post
Since you have a multi select box you have to loop thru the entire checking which is selected
This code will do it:

for (i=0; i if (this.listbox1.options[i].selected) {
alert(i);
}
}

Fernando


Prod WF 8.1.04, QA WF 8.2.03, Dev WF 8.2.03
 
Posts: 278 | Registered: October 10, 2006Report This Post
Guru
posted Hide Post
Fernando, a little bit closer. First I get an alert with the value 0 and when I close that one another alert pop up with the correct value. What causes the first alert to pop up?

I'm on WF 7.1.4 running on localhost on an XP box with Tomcat 5.0.


WebFOCUS DS 8.0.06/08 DS/AS
WebFOCUS RS 8.0.08 (Linux/IBM i)
WebFOCUS Client 8.0.06 (Linux)
 
Posts: 319 | Location: Stockholm, Sweden | Registered: February 04, 2004Report This Post
Expert
posted Hide Post
Hi H Lidholm,

One of our people reviewed the code and here is his suggestion.

This works as expected as the JavaScript event you want to use, is the onChange event and not the onClick event. The below code will demonstrate the differences.

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
  <form name=form1 id=form1>
  <select multiple name=listbox1 id=listbox1 onChange=javascript:onJSChange(); onClick=javascript:onJSClick();>
       <option value=a>A</option>
       <option value=b>B</option>
       <option value=c>C</option>
       <option value=d>D</option>
       <option value=e>E</option>
       <option value=f>F</option>
   </select>
  </form>
<SCRIPT LANGUAGE=javascript>
       var objThis = document.form1.listbox1;
       function onJSClick() { alert('onclick='+objThis.selectedIndex); }
       function onJSChange() { alert('onchange='+objThis.selectedIndex); }
</SCRIPT>
</BODY>
</HTML>


Hope this helps. Big Grin

Cheers,

Kerry


Kerry Zhan
Focal Point Moderator
Information Builders, Inc.
 
Posts: 1948 | Location: New York | Registered: November 16, 2004Report This Post
Guru
posted Hide Post
Kerry, thanks, that works fine, but there seem to be a problem with a listbox in a chain. For some reason the chaining seem to disable the onchange event. If I remove the chaining it works fine. Any ideas?

Håkan


WebFOCUS DS 8.0.06/08 DS/AS
WebFOCUS RS 8.0.08 (Linux/IBM i)
WebFOCUS Client 8.0.06 (Linux)
 
Posts: 319 | Location: Stockholm, Sweden | Registered: February 04, 2004Report This Post
Expert
posted Hide Post
Håkan,

The onchange event removal has been noticed before (sorry, can't locate the posts at the moment) but the way around it it to reassign the onchange event as part of the load procedure.

The code that I use is -
<SCRIPT id=OnloadHandler>
function OnLoad() {
<!--startibilines-->
UpdateData();
<!--endibilines-->
// Overcome a bug in IB's script that clears an onchange event for a select
SelCtrl = document.getElementById("SELECT1");
SelCtrl.attachEvent("onchange", createSelects);
}
// This function adds an event handler to a control
    function createSelects() {
       this.displayElement = window.event.srcElement;
// This next line contains what would normally be in your onchange event action
       Show_Selects(this.displayElement.id);
    }
</SCRIPT>


lycka till!

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Guru
posted Hide Post
Tony,

thanks a lot. However, I decided to have a clickable text below the listbox instead, which will show all the selections made in the listbox using an alert message.

H


WebFOCUS DS 8.0.06/08 DS/AS
WebFOCUS RS 8.0.08 (Linux/IBM i)
WebFOCUS Client 8.0.06 (Linux)
 
Posts: 319 | Location: Stockholm, Sweden | Registered: February 04, 2004Report 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     Problems with multiselect listbox in HTML

Copyright © 1996-2020 Information Builders