Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Create_combo_box

This is a perl script that I wrote to populate a HTML drop down list from an array,

All scripts within this site are free -  mail us if you have any issues or suggestions about the scripts

Modus Operandus

Purpleflash Software See our E-Consultancy Page

Step 1 Create Array - This can be read in from a file or initialised at the start of a script . Change $arrayelement to the number of field in the array that you require.

open(DATA,"$filename");

   @mylines = <DATA>;

 close(DATA);

$arrayelement = 0;

Step 2 Create HTML code - Here we split the array - @mylines -and build up the html code. We have used a subroutine ShowCategories for this. For clarity it is best to put your subroutines at the end of your script .

sub ShowCategories {

$mycategories = "";

foreach $myline (@mylines)

{      @mycdata = split(/,/,$myline);

        {      $mycategories = $mycategories.'<option>'.$mycdata[$arrayelement];

        }

}

Step 3 Call subroutine -

Step 4 Use HTML code - Here is the code that you need to place within a HTML table in your script.

&ShowCategories;

<td><br><FONT COLOR="#FFFFFF"> Category </font><SELECT NAME="category" size="1">$mycategories</select>       <p></td>