Focal Point
[Closed]Populate listbox vertically

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

June 30, 2016, 09:03 AM
Ramya
[Closed]Populate listbox vertically
Hi,

I use the following code to read values from text file and trying to populate them to the listbox. The values are getting added but horizontally as a single value. I need them to be displayed vertically as multiple values.

animals.txt contains the following value
Lion
Tiger
Elephant

--- My Code ----------------------------

SET HOLDLIST=PRINTONLY
FILEDEF TRY DISK ab63221/animals.txt
TABLE FILE TRY
PRINT ANIMAL
ON TABLE SAVE AS ANIMALLIST
END
-RUN


-HTMLFORM BEGIN

Have rest of my HTML code which is not getting displayed in this post

!IBI.FIL.ANIMALLIST;

-HTMLFORM END
----------------------------------------------------------

Thanks,
Ramya
Webfocus 8105, HTML, Javascript

This message has been edited. Last edited by: Ramya,
June 30, 2016, 12:54 PM
Kofi
Ramya,

This very basic know of HTML, Perhaps HTML help might be your wanting?

W3Schools HTML

Kofi


Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
June 30, 2016, 01:42 PM
Squatch
Here is an example with the CAR file:

TABLE FILE IBISAMP/CAR
PRINT
    CAR
WHERE RECORDLIMIT EQ 3
ON TABLE HOLD AS CARJSON FORMAT JSON
END

-HTMLFORM BEGIN
<script type="text/javascript">
function build_listbox() {
	var cars = !IBI.FIL.CARJSON;

// "cars" variable now contains this JSON object:
//
//   {
//     "records" : [
//        { "CAR" : "JAGUAR" },
//        { "CAR" : "JENSEN" },
//        { "CAR" : "TRIUMPH" }
//      ]
//   }

	var listbox = document.getElementById("listbox1");

	for (i = 0; i < cars.records.length; i++) {
		var option = document.createElement("option");
		option.text = cars.records[i].CAR;
		option.value = cars.records[i].CAR;
		listbox.add(option);
	}
}
</script>
<body onload="build_listbox()">
<select id="listbox1"></select>
</body>
-HTMLFORM END



App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
June 30, 2016, 04:59 PM
Doug
You probably need to account for the CR/LF in the text file before loading it...
July 01, 2016, 08:05 AM
Ramya
Thanks All,

I got it done. Simple things never strike when we are into the work.

Regards,
Ramya
Webfocus 8105
HTML,Javascript


WebFocus 7702
HTML
July 01, 2016, 09:27 AM
Doug
So, What's was your solution, the "Simple things never strike when we are into the work."?
July 01, 2016, 09:30 AM
Ramya
Doug,

I have used Squatch's method for displaying them vertically

Thanks,
Ramya
WebFocus 8105,HTML,Javascript
July 01, 2016, 09:35 AM
Doug
Thanks for you feedback Ramya...