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     [SOLVED] Preselect dropdown box value for ONE single &variable

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Preselect dropdown box value for ONE single &variable
 Login/Join
 
Platinum Member
posted
There IS now a "selected value" box that you can specify what you would like as the selected/highlighted value in your drop-down box. !IBI.AMP.varname as opposed to DefaultText does NOT work. In fact, I've been trying alternatives I've found here for 2 days now. None of them work. It would make life SOOOO much simpler if an &variable did work there.

Having said that,

Using a fex to create and set default content of the control, how DO I create a list and set the default (WITHOUT movin the default to the top of the list?

Thanks for any help you can provide!!
ps. I am NOT a javascript programmer. I am not afraid to insert a little in there if that works, but need specifics.

This message has been edited. Last edited by: mpbMDE,


WebFOCUS 8.1.05 Windows 7, all output
 
Posts: 107 | Registered: February 18, 2011Report This Post
Guru
posted Hide Post
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<BASE href=HTTP://localhost:8080>
<SCRIPT id=clientEventHandlersJS type=text/javascript>
function window_onload() {
UpdateData();
document.getElementById("listbox1").selectedIndex = 1;

}

</SCRIPT>

<SCRIPT for=window eventname="onload">window.onload = function() { window_onload(); }</SCRIPT>

<META content="MSHTML 6.00.6000.17095" name=GENERATOR>
</HEAD>
<BODY style="OVERFLOW: auto">
<FORM id=form1>
</FORM>
<SELECT id=listbox1 style="Z-INDEX: 1; LEFT: 270px; WIDTH: 250px; POSITION: absolute; TOP: 110px; HEIGHT: 140px" tabIndex=1 size=3 name=COU datasource="country.fex" displayfield datafield datatype="1" sourcetype="typeFex" ibic_server ibiapp_app="SESSION baseapp" newchainnumber="0">
</SELECT>  
<SPAN id=text1 style="Z-INDEX: 3; LEFT: 200px; WIDTH: 60px; POSITION: absolute; TOP: 130px; HEIGHT: 20px" tabIndex=3>Country 
</SPAN>
</BODY>
</HTML>



Thanks,

Ramkumar.
WebFOCUS/Tableau
Webfocus 8 / 7.7.02
Unix, Windows
HTML/PDF/EXCEL/AHTML/XML/HTML5
 
Posts: 394 | Location: Chennai | Registered: December 02, 2009Report This Post
Guru
posted Hide Post
 document.getElementById("listbox1").selectedIndex = 1;


This is the key here. You can change the SelectedIndex value, as needed to say which Item needs to be selected.


Thanks,

Ramkumar.
WebFOCUS/Tableau
Webfocus 8 / 7.7.02
Unix, Windows
HTML/PDF/EXCEL/AHTML/XML/HTML5
 
Posts: 394 | Location: Chennai | Registered: December 02, 2009Report This Post
Virtuoso
posted Hide Post
That won't work in 7.6.11. The listbox hasn't finished populating yet when the onload function gets called.

Besides, it is a very rough simplification, it just selects the 2nd item in the listbox, which is not what you want.

Try this (off the top of my head):
function onInitialUpdate() {
    document.getElementById("listbox1").value = "!IBI.AMP.varname;";
}


The important part here is that the code to set the default for the dropdown is in onInitialUpdate(), a function called by the IBI libraries after the contents of the form-elements are loaded (which happens asynchronously since 7.6.10 or so, which just means different parts of the page are downloaded in parallel using multiple connections, but the consequence is that it's not as cut-and-dry when the page has finished loading).

Setting a dropdown boxes' value directly (like I did above) doesn't work in IE6, but it should work in later versions (and other browsers).
If you're cursed with IE6, you'll need to iterate through the list of options in the dropdown box until you find the one with the right value, and set it's "selected"-attribute to some value (doesn't matter what, even "false" means true there).
For help with Javascript, I can recommend the Core Javascript Guide at mozilla.


Also noteworthy, "listbox1" in above example refers to the id-attribute of your dropdown form-element (see the properties panel), not to its name-attribute - that seems to be a common mistake among WebFOCUS users.
And... that attribute has to be unique in your HTML page, of course.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Platinum Member
posted Hide Post
I inserted this:
function onInitialUpdate() {
document.getElementById("combobox1").value = "!IBI.AMP.MYCAR;";
}
into my HTML. Then I get NO values in my dropdown box.

Here is my fex that is populating the dropdown box:
-* File defaultcar.fex
-SET &MYCAR = 'TR7';

TABLE FILE CAR
SUM
FST.MODEL
BY MODEL NOPRINT
WHERE COUNTRY EQ 'ENGLAND';
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE PCHOLD FORMAT XML
END
I want the &MYCAR value selected as the default.
Marilyn


WebFOCUS 8.1.05 Windows 7, all output
 
Posts: 107 | Registered: February 18, 2011Report This Post
Member
posted Hide Post
I may be mistaken, but if the variable name being used to indicate the default is the same name as the variable that the listbox is also tied to, the listbox should automatically set the value so long as it actually exists in the list.

Since your having issues with this though, I may be wrong.

In any event, the following could be added to the onInitialUpdate() to set the correct item.

var list = document.getElementById('combobox1');
for(var i=0; i<list.length; i++)
{
  if(list[i].value == '!IBI.AMP.VARNAME;')
    list.selectedIndex = i;
}


WebFOCUS 8.1.04; SQL Server 2012; Windows 7; Windows Server 2012 R2;
 
Posts: 26 | Registered: November 21, 2005Report This Post
Expert
posted Hide Post
quote:
In any event, the following could be added to the onInitialUpdate() to set the correct item.

Only if your HTML is called using -HTMLFORM label syntax.

e.g.

-HTMLFORM BEGIN
your html code
-HTMLFORM END

or

-HTMLFORM your_html_filename

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
Virtuoso
posted Hide Post
quote:
Originally posted by mpbMDE:
Here is my fex that is populating the dropdown box:
-* File defaultcar.fex
-SET &MYCAR = 'TR7';

TABLE FILE CAR
SUM
...


That's the wrong place to set the default value, you need to do that in the fex that includes your HTML page (where you put -HTMLFORM).


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Platinum Member
posted Hide Post
quote:
That's the wrong place to set the default value, you need to do that in the fex that includes your HTML page (where you put -HTMLFORM).


Aha That's why this method doesn't work. The launch page is opened by another application, via the URL. That leaves me with no solution again. Is there a way to do this in the fex that populates the dropdown box? I have seen many variations of the following:
<option value="INTERCEPTOR III">INTERCEPTOR III</option>
<option value="TR7"selected="selected">TR7</option>
<option value="V12XKE AUTO">V12XKE AUTO</option>

They all have slight differeces: spacing, capitaliztion, location and text of the selection phrase.

Anyone know what works in v7.6.11 and the other details I need to implement this?
THANKS!
Marilyn

This message has been edited. Last edited by: mpbMDE,


WebFOCUS 8.1.05 Windows 7, all output
 
Posts: 107 | Registered: February 18, 2011Report This Post
Guru
posted Hide Post
I don't know if I am off base here, but if you always want the &MYCAR var to be TR7 just hard code it in the HTML page like below;

function onInitialUpdate() {
 
var list = document.getElementById('combobox1');
for(var i=0; i<list.length; i++)
{
  if(list[i].value == 'TR7')
    list.selectedIndex = i;
}
 
}



WebFOCUS Server 8.1.05
Windows 2008 Server
WebFOCUS AppStudio 8.1.05
Windows 7 Professional
IE 11 and Chrome Version 43.0.2357.124 m.
Mostly HTML, PDF, Excel, and AHTML
 
Posts: 272 | Location: Kalamazoo, Michigan | Registered: September 30, 2010Report This Post
Platinum Member
posted Hide Post
quote:
'TR7'

Thanks MAdams1!!
I did get this to work. I just changed the 'TR7' to '!IBI.AMP.MODEL;'.
The other thing I did was to make the starting object starthere.fex that simply has this in it:
-* File starthere.fex
-SET &MODEL = 'TR7';
-HTMLFORM LAUNCH_CAR.htm
---------------------------
Now all I have to do is get the incoming &MODEL value from the source. The source is in the URL that starts the fex starthere.fex.

Marilyn


WebFOCUS 8.1.05 Windows 7, all output
 
Posts: 107 | Registered: February 18, 2011Report 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] Preselect dropdown box value for ONE single &variable

Copyright © 1996-2020 Information Builders