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] How to set SYSDATE on drop down list or list box

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[Solved] How to set SYSDATE on drop down list or list box
 Login/Join
 
Member
posted
Hi.

We're trying to set default values for drop down or list box components with the SYSDATE. We found that we can set this with a fix value in the settings panel of a component, section "Selected Value" like this example:



How you can see, "Selected value" is set to "2016", Is there any form to set to the current year?

Thanks in advance.

Leonardo.

This message has been edited. Last edited by: lalvarez13,
 
Posts: 9 | Registered: February 09, 2016Report This Post
<Emily McAllister>
posted
Hello lalvarez13,

To make sure I am understanding you correctly: You want to set the HTML page so that when it is first loaded, '2016' is what is currently highlighted in the dropdown box, is that correct?

I don't think you could do that using the 'Selected Value' area because I don't believe that accepts variables. However, you could write a JavaScript function to do something similar, checking the current year and then changing the selected value of the box to match.

Emily McAllister
Focal Point Moderator
 
Report This Post
Virtuoso
posted Hide Post
It is possible with some little code.

Also using year list coming from a table read instead of the hard coding made for that sample.

Copy/Paste in HMTL Composer (in text mode) and then open with Composer.

The important thing is in onInitialUpdate function

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">


<HTML><HEAD>
<META id=RLT_STANDARDS_MODE_META http-equiv=X-UA-Compatible content=IE=9>
<META name=mycharsetmeta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
<META name=Generation content="Created in release 8105, Generation 3">
<SCRIPT type=text/javascript>//confidential_id=IBI_OptionsScript
var szHtmlAlias="./ibi_html";var szRunTimeHtmlAlias="runTimeHtmlAlias";var cgipath="cgipath";var ibirls="ibirls3";var rltdyncalendar="rltdyncalendar";var map="ibimap";var olap="olap";var olappanebase="olappanebase";var olapdrill="olapdrill";var ibiOptions = new Array(cgipath,ibirls);var nlsScript="/javaassist/nls.js";var glbScript="/javaassist/ibi/html/js/ibigbl.js";var replacePart="<replace>";
var scriptTemplate='<SCRIPT src="'+replacePart+'" type="text/javascript"><\/SCRIPT>';if(typeof(szRunTimeHtmlAlias) === 'string' && szRunTimeHtmlAlias.indexOf('/') == 0)szHtmlAlias=szRunTimeHtmlAlias;document.write(scriptTemplate.replace(replacePart, szHtmlAlias + nlsScript));document.write(scriptTemplate.replace(replacePart, szHtmlAlias + glbScript));</SCRIPT>

<SCRIPT type=text/javascript>//confidential_id=IBI_ibigblloadCss
if(typeof ibigblloadCss === 'function'){ibigblloadCss(null);addIntlTranslatedJS("composertrans.js");}else {alert("JavaScript alias './ibi_html'  is not valid");window.location("about:blank");}</SCRIPT>
<TITLE>HtmlPage</TITLE>
<SCRIPT type=text/javascript>//confidential_id=clientEventHandlersJS


function window_onload() {
	UpdateData();
}

function onInitialUpdate() {

	var CurYR = IbComposer_getCurrentSelection('CURYR');
	IbComposer_setCurrentSelection('YR_LST', CurYR, false);
}

</SCRIPT>

<SCRIPT for=window type=text/javascript eventname="onload">window.onload = function() { window_onload(); }</SCRIPT>
<LINK id=ITEM2 rel=stylesheet type=text/css rtFileName="cgipathsub/ibi_html/javaassist/ibi/html/composer/themes/nonBindows/IBI-Themes/default_theme.css"></HEAD>
<BODY style="OVERFLOW: auto" maptype="0" elementtype="21" thumbnailscale="4" nextelementuniquenumber="12" edaconnectionrequired="true"><SELECT tabIndex=1 id=YR_LST style="WIDTH: 60px; POSITION: absolute; LEFT: 60px; Z-INDEX: 1; TOP: 50px" persistentuniqueid="compUid_1" defaultselection="1" name="YR_LST">
</SELECT> <INPUT tabIndex=2 disabled id=CURYR style="HEIGHT: 22px; WIDTH: 70px; POSITION: absolute; LEFT: 170px; Z-INDEX: 2; TOP: 50px" size=10 persistentuniqueid="compUid_2" defaultselection="1" rawvalue="2016" name="CURYR"> <SPAN tabIndex=3 id=text1 style="HEIGHT: 20px; WIDTH: 340px; POSITION: absolute; LEFT: 170px; Z-INDEX: 3; TOP: 30px" elementtype="4">Hide this field. Set DISPLAY property to No</SPAN> <INPUT id=layoutinfo style="POSITION: absolute; LEFT: -100px; TOP: -100px" type=hidden resourcectrlids="ITEM2" name="inputhidden1"><INPUT id=ibiapp_app style="POSITION: absolute; LEFT: -100px; TOP: -100px" type=hidden ismre="1" name="ibiapp_app"><INPUT id=ibif_ex style="POSITION: absolute; LEFT: -100px; TOP: -100px" type=hidden value=/WFC/Repository/itr6g4h7/yyyyy.htm name="ibif_ex"><xml id=focus_xmlelement><script type="text/xml" nextelementuniquenumber="3">
	<rootxmlnode focoption="_FOC_NULL">
		<variables></variables>
		<input_controls>
			<input_control bindcontrolid="compUid_1" elementtype="8" name="YR_LST" id="YR_LST" multiple="0" onetimepopulated="0">
				<link linktype="default" persistentuniqueid="compUid_1">
					<condition default="1" name="Default" whattodowithcontrol="0" valuescompareoperator="0" parameterscompareoperator="0" conditionmultiselectoperator="0">
						<data_info checkForDuplicateValues="0" sourcetype="typeMaster" modifiedrequest="1" datatype="1" datafield="YR" displayfield="YR_LST" selectedvalue="">
							<![CDATA[SET ASNAMES ON
TABLE FILE CAR
PRINT COMPUTE YRSTR /YY = 2010; NOPRINT
      COMPUTE ID /P4 = ID + 1;  NOPRINT
      COMPUTE YR_LST /P4 = YRSTR + ID;
BY TOTAL COMPUTE YR /P4 = YRSTR + ID;
BY CAR NOPRINT
WHERE READLIMIT EQ 10;
ON TABLE PCHOLD FORMAT XML
END]]></data_info></condition></link></input_control>
			<input_control bindcontrolid="compUid_2" elementtype="7" name="CURYR" id="CURYR" multiple="0" onetimepopulated="0">
				<link linktype="default" persistentuniqueid="compUid_2">
					<condition default="1" name="Default" whattodowithcontrol="0" valuescompareoperator="0" parameterscompareoperator="0" conditionmultiselectoperator="0">
						<data_info checkForDuplicateValues="0" accept="0" sourcetype="typeMaster" datatype="1" modifiedrequest="1" datafield="CURYR" displayfield="CURYR">
							<![CDATA[DEFINE FILE CAR
DTEX      /A10    = FPRINT(&YYMD, 'D10c', 'A10');
DTE       /HYYMDs = HINPUT(10, DTEX, 8, DTE);
CURYR     /I4     = HPART(DTE, 'YEAR',  'I4');
END
TABLE FILE CAR
SUM CURYR
BY CAR NOPRINT
WHERE READLIMIT   EQ 1;
WHERE RECORDLIMIT EQ 1;
ON TABLE PCHOLD FORMAT XML
END]]>
</data_info></condition></link></input_control>
		</input_controls>
		<other_bound_objects></other_bound_objects>
		<requests></requests></rootxmlnode></script>
</xml></BODY>
<SCRIPT type=text/javascript>//confidential_id=IBI_loader
if(typeof doBeforeLoad === 'function'){doBeforeLoad();}function AdjustChildrenPosition(){
}
</SCRIPT>
</HTML>
<!-- cc kvyv -->


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: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Member
posted Hide Post
I use a fex to set the defaults and then load the html page.

-* run_menu.fex
-SET &YEAR  = EDIT(&YYMD,'9999');
-TYPE &YEAR

-HTMLFORM IBFS:/WFC/Repository/somefolder/menu.htm


In the "Selected Value" box put...
!IBI.AMP.YEAR;



 
Posts: 23 | Location: Cincinnati, OH | Registered: September 25, 2013Report This Post
Virtuoso
posted Hide Post
Teri's option will work until you don't have the IBI SaveOption button in your page.

The SaveOtion saved the "menu.htm" as the executable member and not the "menu.fex" meaning that your variables WON'T be initialized on loading (execution) of a "SavedOption" file if their setting is coming from the fex.

I've also heard that
!IBI.AMP
may not be recognized in future release...but this may just be a rumor...


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: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Master
posted Hide Post
You can change a drop down's default selection with a little JavaScript. The trick is to have the code execute after the drop down has finished loading its selection values (from whatever source).

The place to do that is the "After Load" event for the drop down. In App Studio, you access events in the Properties panel by clicking on the yellow lightning bolt. Double-click on "After Load" and insert the following code (which assumes the drop down is called "combobox1"):

function combobox1_ononafterload(ctrl) {
    // Get current year from system date/time.
    var d = new Date();
    var year = d.getFullYear();

    // Look at all possible selections in drop down control.
    // If current year matches one of the years in the drop down,
    // then make that year the default selection.
    var dropdown = document.getElementById("combobox1");
    var options = document.getElementById("combobox1").options.length;

    for(var i = 0; i < options; i++) {
        if (year.toString() == dropdown[i].value.toString()) {
            dropdown.value = dropdown[i].value;
        }
    }
}

This example assumes a drop down loaded with the following years, with 2012 as the default selection:

2012
2013
2014
2015
2016

The code above changes the default selection to 2016 immediately after the drop down appears.

UPDATE: A single-select list box is handled the same way as a drop down. Just change "combobox1" to "listbox1" or whatever the list box is named.

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


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Master
posted Hide Post
quote:
function combobox1_ononafterload(ctrl) {
// Get current year from system date/time.
var d = new Date();
var year = d.getFullYear();

// Look at all possible selections in drop down control.
// If current year matches one of the years in the drop down,
// then make that year the default selection.
var dropdown = document.getElementById("combobox1");
var options = document.getElementById("combobox1").options.length;

for(var i = 0; i < options; i++) {
if (year.toString() == dropdown[i].value.toString()) {
dropdown.value = dropdown[i].value;
}
}
}



That is way too much work to do this simple thing..

This will do the same thing if the value exists, else it will be ignored..

<script>
function setCombo() {
    // Get current year from system date/time.
    var d = new Date();
    document.getElementById("combobox1").value = d.getFullYear();
}
</script>
<body onload="setCombo()">
....
</body>



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Master
posted Hide Post
quote:
Originally posted by GavinL:
That is way too much work to do this simple thing..

This will do the same thing if the value exists, else it will be ignored..

<script>
function setCombo() {
    // Get current year from system date/time.
    var d = new Date();
    document.getElementById("combobox1").value = d.getFullYear();
}
</script>
<body onload="setCombo()">
....
</body>

In all browsers? I wish I had your confidence.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Expert
posted Hide Post
So, for something as simple as selecting the current year in a drop-down list, the GUI user must resort to code?

The GUI user will eventually become a developer - yay!


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Master
posted Hide Post
quote:
Originally posted by Francis Mariani:
So, for something as simple as selecting the current year in a drop-down list, the GUI user must resort to code?

The GUI user will eventually become a developer - yay!

Yes, there should be at least one more button in the GUI to take care of that for me. It should be a big button, too, labeled something like "Select current year in this drop-down list."

How does one go about asking for a new feature like that?


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Expert
posted Hide Post
Open a Tech Support case for a "New Feature Request".


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Master
posted Hide Post
quote:
Originally posted by Francis Mariani:
Open a Tech Support case for a "New Feature Request".

I hear they tend to ignore even the really good feature requests, so I don't think I stand a chance on this one.

On the other hand, for the GUI to eliminate the need for programmers, and to solve poverty, and to stop all wars, I suppose they will eventually have to add the "Select current year in this drop-down list" button.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Expert
posted Hide Post
Agree 100%


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Master
posted Hide Post
quote:
In all browsers? I wish I had your confidence.


This is Javascript v1, which is supported by all browsers and the same code you have, just sum'd up without the looping.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Master
posted Hide Post
quote:
Originally posted by GavinL:
quote:
In all browsers? I wish I had your confidence.


This is Javascript v1, which is supported by all browsers and the same code you have, just sum'd up without the looping.

You might end up getting the same result, but it's not the same code.

Your code takes it on faith that nothing unusual will happen when trying to default the drop down selection to a value not in the original drop down list. If it ends up working that way, then good for you. I'll take a different route.

My code only sets a default value if it is already in the original drop down list, so no possible side effects and no need to know which version of JavaScript ignores what.

And as a bonus, code can be added into the looping structure to allow for the insertion of a default value if it is not already in the drop down list (In this case, "2016"). So if someone has to modify my code in the future and do just that, he or she will have an easier time of it. From their point of view, I doubt they will think what I coded was "way too much work."


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Master
posted Hide Post
Well I don't want to get into a squatching match with you, pun intended, about Javascript, but your code is doing exactly the same thing as mine outside the loop. I've been doing Javascript for 20 years.

1. Your loop is actually very bad on the basis you don't know how much data you have in it and causes the end users browser to lock up while it's looping.
2. By telling a control to set a value, if the value exists, it will be set else it is ignored and has always been ignored. It has at no time ever cause and error by any browser.

This was set by W3C standards.
http://www.w3schools.com/jsref/prop_select_value.asp

Property Values
value - Specifies the value of an <option> element in a drop-down list that should get selected. If the value does not exist, the drop-down list will display an empty option



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Master
posted Hide Post
quote:
Originally posted by GavinL:
1. Your loop is actually very bad on the basis you don't know how much data you have in it and causes the end users browser to lock up while it's looping.

I know how much drop down data I'm working with. I'm designing the application.

If I have to work with a bazillion drop down entries, then perhaps I need to rethink my approach. And with that many choices, I don't think there would be much of a need to use JavaScript to highlight one in particular, anyway. The original poster was talking about a list of years, and I don't think he was intending to go back to the year Christ was born.

With that much hypothetical data it's going to be slow, anyway. WebFOCUS has to bring in all that data to populate the drop down control. So it will suck anyway. My example was for a reasonable drop down list only.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Platinum Member
posted Hide Post
If you just want the current year, I swear I have done this by sorting the list in descending order and always selecting the first row displayed. But my memory is getting faulty now. Oh, and just select the most recent 10 years or so.


WebFOCUS 7.7.05 (Someday 8)
Windows 7, All Outputs
In Focus since 1983.
 
Posts: 103 | Registered: April 27, 2011Report This Post
Master
posted Hide Post
quote:
Originally posted by Kevin W:
If you just want the current year, I swear I have done this by sorting the list in descending order and always selecting the first row displayed. But my memory is getting faulty now. Oh, and just select the most recent 10 years or so.

It looks like the original poster wants years sorted in ascending order, but with the current year as the default. That's my interpretation.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Member
posted Hide Post
Hi there.

Problem solved, the Squatch solution worked like a charm!

Thank you so much.

Regards,

Leonardo.
 
Posts: 9 | Registered: February 09, 2016Report This Post
Platinum Member
posted Hide Post
Well, if you just select the most recent 10 years and select the 10th row as the default it works for descending. But, I'm glad you guys got it working. I too have users that want to see data from the beginning of time.


WebFOCUS 7.7.05 (Someday 8)
Windows 7, All Outputs
In Focus since 1983.
 
Posts: 103 | Registered: April 27, 2011Report This Post
Member
posted Hide Post
Hey Guys! I can't tell you how many times I have used this code! Thanks for providing!! I have a little different twist to it for my current HTML page. What if I want to read a flat file that has the "default" value in it for year, how would I do that instead of using the current date. So in other words, if I want to use year=2015 as my default year instead of 2016. I would prefer to read a file instead of doing something in JS as I don't know what the year will be.

Thanks again for this tip!!


WF 8.1.0.5
Windows, Unix, MVS
HTML, PDF, PPT, EXCEL, USER, FOCUS
 
Posts: 10 | Registered: April 14, 2009Report This Post
Expert
posted Hide Post
I would add a hidden text box control which reads the value. Then some minimal JS to set the select listbox to the value of this hidden control.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report 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] How to set SYSDATE on drop down list or list box

Copyright © 1996-2020 Information Builders