Focal Point
[CLOSED] HTML, javascript and .fex

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

September 26, 2011, 10:22 AM
jhasty
[CLOSED] HTML, javascript and .fex
Does anyone know of a way to read a field from a .fex (or database) using javascript and then populate a text box in an HTML form with the data from that field?
Example: I have an HTML form where the user can select to view, add, modify, delete records. What I'd like to happen, when they select modify, is for the text boxes to update with the data from the record they have selected to modify. They would select the record by either entering an id number or selecting from a drop down. I think I understand how to set the value using javascript, just not sure if there is a way to read the values from the .fex (or database) in order to work with them in javascript.
Thanks in advance for any assistance anyone can offer.

I am on webfocus version 7702.

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


WebFOCUS 8008
Windows, All Outputs
September 26, 2011, 01:47 PM
<FreSte>
I would recommend using jQuery.
Maybe you can get some inspiration from this post.

-Fred-
September 26, 2011, 05:42 PM
Waz
There are many ways to do this.

A method I use is to use IBI's xmlhttp aupport script library.

Your fex just PCHOLDs the data format XML.

The call is made through this object, and the answerset is available to javascript.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

September 26, 2011, 06:43 PM
Waz
Here is an example I just knocked up...

HTML part: (fp_xmlhttp.html)
You will have to change the IBIAPP_app to your location.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
 <head>
  <title> My Report </title>
  <meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
  <SCRIPT id=IBI_OptionsScript type=text/javascript>
    var ibiOptions = new Array("ibihttpxml") ;
  </script>
  <script type="text/javascript" language="Javascript" src="/ibi_html/javaassist/ibi/html/js/ibigbl.js"></SCRIPT>
  <script type="text/javascript">
   <!--
    function funGetData() {
     var ibihttp = new ibihttpxml("/ibi_apps/WFServlet",null) ;
     ibihttp.openFromForm(document.forms.My_Form) ;
     alert(ibihttp.xmlhttp.responseText) ;
     var CtySales = ibihttp.selectSingleNode("//fxf/report/table/tr/td");
     document.getElementById("SALES").value = ibihttp.getNodeText(CtySales) ;
    }
   //-->
  </script>
 </head>

 <body onload="">
  <form method="post" name="My_Form">
   <table>
    <tr>
     <td>Country</td><td><input type=text name="COUNTRY" value="ENGLAND"></td>
    </tr>
    <tr>
     <td>Sales</td><td><input type=text name="SALES" id="SALES"></td>
    </tr>
    <tr>
     <td><input type=button value="Get Sales" onclick="funGetData()"></td>
     <td></td>
    </tr>
   </table>
   <input type=hidden name="IBIF_ex" value="fp_xmlhttp">
   <input type=hidden name="IBIAPP_app" value="focalpoint">
 </form>
 </body>
</html>


Fex part: (fp_xmlhttp.fex)
TABLE FILE CAR
SUM SALES
WHERE COUNTRY EQ '&COUNTRY'
ON TABLE PCHOLD FORMAT XML
END



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

September 27, 2011, 08:10 AM
jhasty
Thank you both for the suggestions - I will review this information today and let you know how it turns out.


WebFOCUS 8008
Windows, All Outputs
October 10, 2011, 04:48 PM
jhasty
Hi Waz,

I am giving your method a try. I think I am pretty close, but cannot seem to get the textbox I am using to populate. I was able to successfully get your demo to work, and then convert it to pull the data from my data sources and change the variable and field names. The issue comes in when I try to figure out how to implement this into a form that I have already developed in HTML composer. Even if I open the demo in HTML composer (vs text editor), there is a lot of additional code that is inserted, making it very difficult for me to keep things straight. I know this is a difficult question to answer without seeing my code, but are there some tips you can share that might help me troubleshoot what is missing?

One error that I am seeing is "no valid cgi request to process." "Webfocus was called with an invalid request."

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


WebFOCUS 8008
Windows, All Outputs
October 10, 2011, 05:02 PM
Waz
If you like, send me a PM with your code, and I'll take a look.

I suspect much of the infrastructure will already be there, so adding the code may be easy.

As with another post I saw today, the HTML composer likes to rewrite the code, so adding inside composer, I guess, may be the best way, if not add it manually and don't go back to composter.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 13, 2011, 04:20 PM
jhasty
Hi Waz - I sent you a PM regarding this, let me know if you didn't receive and I will try again.
Thanks.


WebFOCUS 8008
Windows, All Outputs
October 13, 2011, 05:46 PM
Waz
I got it, but am very busy at the moment.

You've added the script OK, but getting the ibihttpxml added and stay there if you reopen in composter will be more difficult.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 13, 2011, 06:32 PM
Dan Satchell
quote:
composter
Waz, I love it. I'll never be able to say the real name again.


WebFOCUS 7.7.05
October 13, 2011, 08:39 PM
Francis Mariani
Me too! What a great name!!!


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 13, 2011, 08:48 PM
Waz
I think the first time was a typo.

Winky


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 17, 2011, 03:31 PM
David Briars
Waz,

Many thanks for the clear simple example of using IBI's xmlhttp support script library. (Definitely very helpful to an xmlhttp newbie like me.)

I was able to implement your example A-OK in my environment (MRE).

Dave

This message has been edited. Last edited by: David Briars,
October 17, 2011, 04:09 PM
Francis Mariani
quote:
Many thanks for the clear simple example of using IBI's xmlhttp support script library.

How dare this be a secret? Winky


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 17, 2011, 05:06 PM
Waz
Its only a secret if you don't go looking for it......


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 21, 2011, 11:47 AM
jhasty
Waz - I was able to get this to work as well. I just had some extra /form tags in my code and needed to connect the control name to the .fex I was using.

Thanks again for the help.

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


WebFOCUS 8008
Windows, All Outputs