Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    List content of item in the combobox

    I have a combo.cgi here. this is linux environment
    What i am going to do is this combobox will list down all the flatfile name in this /u/test/cgi-bin/List directory.
    after that, i wanted it to open the flatfile and display the content of the flatfile into another listbox or textarea in this page once the item is selected in the combobox.
    Pls guide me here

    Code:
    print "Content-type: text/html\n\n";
    print "<html><head>";
    print "</head><body>";
    
    
    @testList = `ls -1 /u/test/cgi-bin/List`;
    
    
    	print "<select name=\"testDropList\">";
    	print "<option></option>";
    for(@testList){
    	$testName = $_;	
           	print "<option value=\"$testName\">$testName</option>";
    }
    	print "</select>";

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,871
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Why have you posted a new/duplicate question when you haven't responded to oesxyl in your first post of this issue?

  • #3
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i did not post duplicate. because last time i post in the wrong section. then now only it been transfer here.

  • #4
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,871
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Specifically which portion of the task do you not know how to do, or is giving you trouble?

    What have you tried beyond what you've posted?

    What errors/warnings are you receiving?

    -----

    Here's some guidance on the code you posted.

    1) you need to learn about Perl's different methods of quoting so you can avoid the "leaning tower" escapes

    2) use the CGI module; it can simplify some of your html coding. For example, those first 3 lines could be reduced/simplified to:
    Code:
    print $cgi->header, $cgi->start_html;
    3) don't use backticks to shell out to the ls command. Perl has several built-in methods for retrieving the file list.

    4) this:
    Code:
    for(@testList){
    	$testName = $_;
    would be better written as:
    Code:
    for my $testName ( @testList ) {

  • #5
    New to the CF scene
    Join Date
    May 2011
    Location
    Cyprus
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    perfect things

    looks like perfect things !


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •