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.
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,
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.
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, 2013
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, 2015
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
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, 2015
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, 2015
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, 2015
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, 2015
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.
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
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, 2015
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.
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, 2015
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.
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.