Focal Point
[SOLVED] Chaining option

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/45710419

April 23, 2009, 03:17 PM
jlsnyc
[SOLVED] Chaining option
When using chaining, it all works fine if you manually change the values in the comobox. However if we change the value in comobox using javascript EX: document.form2.region.selectedIndex = 2;

then chaining doesn't work

Why

This message has been edited. Last edited by: Kerry,
April 23, 2009, 03:29 PM
Francis Mariani
Because JavaScript functions are triggered by the onChange event. If you're changing the selected value in a select list with JavaScript, you have to call the Javascript normally called by the OnChange event - the onChange is not detected when JavaScript is used.


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
April 23, 2009, 03:49 PM
dhagen
As Francis typed, try:
document.form2.region.onchange();


This may not work, but standard DOM references will. If the id of the select box is 'combobox1', then it would be:
document.getElementById('combobox1').onchange();



"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
April 23, 2009, 03:57 PM
Francis Mariani
Thanks for that code.


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
April 23, 2009, 06:10 PM
jlsnyc
What we are doing is. A reset button is used to rest the combobox back to the first Value.

after the combobox has been reset by javascript the chained combobox still have the values from the parent combobox before the reset.

Example. If we reset the first box to all the second should be loaded with all values. mannully this works, but don't if you change it with Javascript.
April 27, 2009, 06:51 PM
StuBouyer
As Francis already pointed out, what you are seeing is the normal behaviour when changing HTML controls with javascript. A change from javascript doesn't count as an OnChange() for that control.

So when you reset the combobox with javascript, the HTML and WebFOCUS are not yet aware of the change. Use the code that dhagen posted or try the populateDynamicCtrl(ctrl); to force the chaining code to run.

Cheers

Stu


WebFOCUS 8.2.03 (8.2.06 in testing)
April 28, 2009, 02:16 AM
Tony A
I do this many times when I pull a value for a particular User - I store the last choice made by a user so that they can be presented with that the next time they run the process.

All you have to issue after changing the selectedIndex value is -

   DoResetDownChainControls(document.getElementById("combobox1"));
Where combobox1 is the Id of the control you have just changed. The JavaScript function "DoResetDownChainControls" is contained in ibirls2.js as supplied by IB.

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 
May 07, 2009, 09:58 PM
jlsnyc
Thanks alot guys, it worked