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] Create Drop Down List Box With IBI's xmlhttp Support Script Library.

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Create Drop Down List Box With IBI's xmlhttp Support Script Library.
 Login/Join
 
Master
posted
My goal is to create a Product Code drop down list box, using sample GGSALES data.

For example:
<select id="ProdCodes" name="ProdCodes">
  <option value="C141">C141</option>
  <option value="C142">C142</option>
</select> 


I am creating my GGSALES XML data with the TABLE command (getprods.fex):
APP PREPENDPATH IBISAMP
TABLE FILE GGSALES
SUM PCD
BY  PCD
ON TABLE PCHOLD FORMAT XML
END


And rendering my page, with -HTMLFORM BEGIN (showprods.fex):
-DEFAULTH &IBIMR_domain='MR Domain Name Not Available'
-TYPE Current MR Domain Name is: &IBIMR_domain
-SET &DOMAIN_NAME = &IBIMR_domain;
-SET &FOLDER_NAME = '#foldername';
-* Create a random number.
-SET &RANDOM = RDUNIF(D5) * RDUNIF(D5) * 10000;
-*
-HTMLFORM BEGIN
<!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 PrdCds = ibihttp.selectSingleNode("//fxf/report/table/tr/td");
          document.getElementById("ProdCodes").options.length = 0; 
          document.getElementById("ProdCodes").options[0] = new Option(ibihttp.getNodeText(PrdCds), ibihttp.getNodeText(PrdCds));
      }

	  function subform() {
	   var myindex  = document.My_Form.ProdCodes.selectedIndex;
       var myvalue  = document.My_Form.ProdCodes.options[myindex].value;
       alert('Selected Product Code: ' + myvalue);
	  } 
   //-->
  </script>
 </head>

 <body onload="">
  <form method="post" name="My_Form">
   <table>
    <tr>
     <td>Product Codes</td>
	 <td>
	   <select id="ProdCodes" name="ProdCodes">
        
      </select>
	 </td>
    </tr>
    <tr>
     <td><input type=button value="Get Product Codes" onclick="funGetData()"></td>
     <td></td>
    </tr>
	<tr>
     <td><input type=button value="Submit Form" onclick="subform()"></td>
     <td></td>
    </tr>
   </table>
-* Variables passed from web page to WebFOCUS servlet.
-*   -WebFOCUS related variables.
-*
   <input type="hidden" name="IBIMR_domain" value="!IBI.AMP.DOMAIN_NAME;">
   <input type="hidden" name="IBIMR_action" value="MR_RUN_FEX">
   <input type="hidden" name="IBIMR_sub_action" value="MR_STD_REPORT">
   <input type="hidden" name="IBIMR_fex" value="app/getprods.fex">
   <input type="hidden" name="IBIF_fex" value="app/getprods.fex">
   <input type="hidden" name="IBIMR_folder" value="!IBI.AMP.FOLDER_NAME;">
   <input type="hidden" name="IBIMR_random" value="!IBI.AMP.RANDOM;">
   <input type="hidden" name="IBIMR_flags" value="">
   <input type="hidden" name="IBIMR_drill" value="RUNNID">
-*
 </form>
 </body>
</html>
-HTMLFORM END


With this, I see only one option rendering in my dropdown list - 'C141'.

At the moment, I only know how to pull a single (first) row from the XML:
var PrdCds = ibihttp.selectSingleNode("//fxf/report/table/tr/td");


How can I pull the entire 'array' of Product Code elements?

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




Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
 
Posts: 822 | Registered: April 23, 2003Report This Post
Expert
posted Hide Post
Use selectNodes, and not selectSingleNode.

Then use:
for (var _c1=0;_c1<PrdCds.length;_c1++) {
 _Kids = PrdCds[_c1].childNodes ;
 for (var _c2=0;_c2<_Kids.length;_c2++) {// There should only be one, if one column returned.
  alert(_Kids[_c2].nodeTypedValue) ;
 }
}


This is quickly typed, and not tested.


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Master
posted Hide Post
Thank you Waz!

Using the selectNodes method to create the NodeList of all Product Codes is exactly what I needed to do, to create my Product Code drop down list box.

showprods.fex:
-DEFAULTH &IBIMR_domain='MR Domain Name Not Available'
-TYPE Current MR Domain Name is: &IBIMR_domain
-SET &DOMAIN_NAME = &IBIMR_domain;
-SET &FOLDER_NAME = '#foldername';
-* Create a random number.
-SET &RANDOM = RDUNIF(D5) * RDUNIF(D5) * 10000;
-*
-HTMLFORM BEGIN
<!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">
  
// Create Product Code Drop Down List Box Contents.  
  function funGetData() {
   var ibihttp = new ibihttpxml("/ibi_apps/WFServlet", null);
   ibihttp.openFromForm(document.forms.My_Form);
   //alert(ibihttp.xmlhttp.responseText);
   // Create Node List Collection of all Product Codes.  
   var PrdCds = ibihttp.selectNodes("//fxf/report/table/tr");
   // Initialize Product Code Drop Down List Box.  
   document.getElementById("ProdCodes").options.length = 0;
   // Scroll Through the Product Code Node List.  
   for (var i=0; i<PrdCds.length; i++) {
    Kids = PrdCds[i].childNodes ;
    document.getElementById("ProdCodes").options[i] = new Option(Kids[1].nodeTypedValue, Kids[0].nodeTypedValue);
   }
  }

// Submit the Form.  
	  function subform() {
	   var myindex  = document.My_Form.ProdCodes.selectedIndex;
       var myvalue  = document.My_Form.ProdCodes.options[myindex].value;
       alert('Selected Product Code: ' + myvalue);
	  }
  </script>
 </head>

 <body onload="">
  <form method="post" name="My_Form">
   <table>
    <tr>
     <td>Product Codes</td>
	 <td>
	   <select id="ProdCodes" name="ProdCodes">

      </select>
	 </td>
    </tr>
    <tr>
     <td><input type=button value="Get Product Codes" onclick="funGetData()"></td>
     <td></td>
    </tr>
	<tr>
     <td><input type=button value="Submit Form" onclick="subform()"></td>
     <td></td>
    </tr>
   </table>
-* Variables passed from web page to WebFOCUS servlet.
-*   -WebFOCUS related variables.
-*
   <input type="hidden" name="IBIMR_domain" value="!IBI.AMP.DOMAIN_NAME;">
   <input type="hidden" name="IBIMR_action" value="MR_RUN_FEX">
   <input type="hidden" name="IBIMR_sub_action" value="MR_STD_REPORT">
   <input type="hidden" name="IBIMR_fex" value="app/getprods.fex">
   <input type="hidden" name="IBIF_fex" value="app/getprods.fex">
   <input type="hidden" name="IBIMR_folder" value="!IBI.AMP.FOLDER_NAME;">
   <input type="hidden" name="IBIMR_random" value="!IBI.AMP.RANDOM;">
   <input type="hidden" name="IBIMR_flags" value="">
   <input type="hidden" name="IBIMR_drill" value="RUNNID">
-*
 </form>
 </body>
</html>
-HTMLFORM END


getprods.fex
APP PREPENDPATH IBISAMP
TABLE FILE GGSALES
SUM PRODUCT
BY  PCD
ON TABLE PCHOLD FORMAT XML
END
 
Posts: 822 | Registered: April 23, 2003Report 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] Create Drop Down List Box With IBI's xmlhttp Support Script Library.

Copyright © 1996-2020 Information Builders