Focal Point
[SOLVED] trigger button on HTML parameter page from iframe report

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

October 05, 2011, 08:56 PM
gregv
[SOLVED] trigger button on HTML parameter page from iframe report
Hi,

Does anyone have javascript to reference a button on an HTML parameter page from inside a report that is running in an iframe that is using WEBVIEWER to display?

What I've tried:
top.document.getElementId("button1")
window.document.getElementId("button1")
parent.document.getElementId("button1")
document.frames.iframe1.report.document.getElementId("button1")
top.frames.iframe1.document.getElementId("button1")

All with no success.
Ideas?
TIA

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



Greg



current client: WF 8.1.05 & 8.2 - Windows 7 64bit - Tomcat 7 - MRE / BID - IE11

local: WF 8.2 - Windows 7 64bit - Tomcat 6 - MRE / BID - FOCUS - IE11

PMF 8
October 06, 2011, 08:25 AM
ERINP
gregv,
Have you tried viewing the rendered HTML output for the button in question??

ERINP


WebFOCUS 7.6.9

Reporting client Windows 2003 Service pack 2 using IIS and TomCat 5.5
Reporting Server OS/400 V5R4M0
Outputs: HTML, Excel, PDF, CSV, and Flat Files
October 06, 2011, 09:00 AM
PBrightwell
This may be a stupid question, but why are you wanting to reference a button from inside a report?


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
October 06, 2011, 10:20 AM
Francis Mariani
First of all it's not "getElementId", it's "getElementById".


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
October 06, 2011, 10:38 AM
ERINP
Nice catch Francis...that should do it...


WebFOCUS 7.6.9

Reporting client Windows 2003 Service pack 2 using IIS and TomCat 5.5
Reporting Server OS/400 V5R4M0
Outputs: HTML, Excel, PDF, CSV, and Flat Files
October 06, 2011, 10:45 AM
Francis Mariani
There's
"opener.document...", "parent.opener.document...",
"self.opener.document...",
"window.opener..."

and even "window.opener.parent.parent.frames"

...

I've used 'em all.


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
October 06, 2011, 11:06 AM
gregv
Thanks all for your suggestions. No joy.

PBrightwell: the reason I want to access a button on the html parameter page from the report is to re-enable the Run button after the user clicks it (I disable it onclick) and the report is displayed. That way they can't click it twice. This should work if i can just get a reference back to the top.document.

Has anyone used a hidden popup window for communication purposes?

Thanks.



Greg



current client: WF 8.1.05 & 8.2 - Windows 7 64bit - Tomcat 7 - MRE / BID - IE11

local: WF 8.2 - Windows 7 64bit - Tomcat 6 - MRE / BID - FOCUS - IE11

PMF 8
October 06, 2011, 11:29 AM
Wep5622
Is its 'id'-attribute really 'button1', or is that perhaps the value of its 'name'-attribute (a common mistake)?
Is the 'button1' id unique in the page?

Is that button inside a frame by itself, perchance?
If so, you'll have to figure out how both documents (the WEBVIEWER frame document and the report frame document) fit in the top document hierarchy. Firefox+FireBug addon can be helpful there, as can some other tools.

If the button is in a frame, you could use something like:
top.document.getElementById('id of WEBVIEWER frame').getElementById('button1');



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 :
October 06, 2011, 12:03 PM
njsden
Since the report is using WEBVIEWER, it apparently creates an iframe on its own so, if you're already using an outer iframe, to access any element in the HTML parameter form you may need to access the report's parent's parent document node Confused

Bah! Code speaks better than words:
DEFINE FILE CAR
SHOWME/A500 WITH CAR = '<input type="button" value="Show" onclick="' ||
                          'var x=parent.parent.document.getElementById(''runButton''); ' ||
                          'if(x) { x.value=''Again!'';}' ||
                       '">';
END
TABLE FILE CAR
PRINT 
     CAR.ORIGIN.COUNTRY
     CAR.COMP.CAR
     CAR.CARREC.MODEL
     CAR.BODY.BODYTYPE
     CAR.BODY.SEATS
WHERE CAR.ORIGIN.COUNTRY EQ '&PCOUNTRY.(FIND CAR.ORIGIN.COUNTRY,CAR.ORIGIN.COUNTRY IN car).Country.';
ON TABLE SUBFOOT
"<SHOWME"
ON TABLE SET PAGE-NUM NOLEAD 
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET WEBVIEWER ON
ON TABLE SET WEBVIEWTARG OFF
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     INCLUDE = endeflt,
$
ENDSTYLE
END


Due to lazyness, I'm relying on auto-prompting as produced in my 7.7.03 environment which auto-magically:

- Creates a basic form with a Country drop-down list and "Run" button (id="runButton")
- Creates an iframe to display the report upon clicking "Run"

From within the WEBVIEWER report, I can reference parent.parent.document.getElementbyId('runButton') and do whatever I want (or can). The sample code changes it's value/caption from "Run" to "Again!" but of course you have more serious needs Smiler

Hope this helps.

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



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
October 06, 2011, 12:56 PM
gregv
njsden: That's it! Good One

Thanks!



Greg



current client: WF 8.1.05 & 8.2 - Windows 7 64bit - Tomcat 7 - MRE / BID - IE11

local: WF 8.2 - Windows 7 64bit - Tomcat 6 - MRE / BID - FOCUS - IE11

PMF 8