I have a drop down list which is currently hard coded with a few options.But i want to populate it through a text file.

E.g. Here the options in my code are Image, Fimage and other and i want to populate it through a text file.

I would like to know whether dynamically populating a combo box through a text file is possible or not, because i have been stuck at this point for some time.

I am posting my script below

#!/usr/bin/perl -w use CGI::Ajax; use CGI; sub Show_HTML { my $html = <<EOT; <HTML> <HEAD><title>Dynamic combo box</title> </HEAD> <BODY> <script type="text/javascript"> function CheckIsNumeric() { var AsciiCode = event.keyCode; if ((AsciiCode < 48) || (AsciiCode > 57)) { alert('Please enter only numbers.'); event.cancelBubble = true; event.returnValue = false; } } function display(selector,inputID) { var selector=document.getElementById(selector); var inputID=document.getElementById(inputID); if (selector[selector.selectedIndex].value=="Other") { inputID.style.display= "block"; } else { inputID.style.display="none"; } } </script> <form name="orderform" method="GET" > <input type="radio" name="pick" value="fun1" checked="checked">Func1 &nbsp; &nbsp; <input type="radio" name="pick" value="Fun2" />Func2<br /> <br> Enter a number : &nbsp; &nbsp; <input type="text" name="Number" id="myText" size="6" onkeypress = +"CheckIsNumeric()"/> <br> <br> Enter a value : <select name="Function1" id="f1" STYLE="width: 150px" onchange="re +turn display('f1','b1');"> <option value="image">Image</option> <option value="fimage">fImage</option> <option value="Other">other, please specify:</option> </select> <input type="text" name="box1" id="b1" size="25" style="display: n +one;"> <br> <br> Enter val2 : &nbsp; &nbsp; &nbsp; <input type="text" name="box2" id="b2" size="40"> <br> <br> <input type="submit" value=" Submit " /> </Form> <form name = "Log file" method = "POST" Action="http://localhost/~Ab +c/log.txt"> Click Here to View the Log file : <input type="submit" value="Log File" /> <br> <br> <hr> <br> </Form> </BODY> </HTML> EOT return $html; } my $cgi = new CGI(); my $pjx = new CGI::Ajax( 'functions' => \&functions ); print $pjx->build_html($cgi,\&Show_HTML); $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/; if ($ENV{'REQUEST_METHOD'} eq "GET") { &functions(); } else {} sub functions { print "Radio Button's Value is : " . $cgi->url_param('pick'); print "<br>"; print "Number's Value is : " . $cgi->url_param('Number'); print "<br>"; print "box1's Value is : " . $cgi->url_param('b1'); print "<br>"; print "box2's Value is : " . $cgi->url_param('b2'); print "<br>"; print "<br>"; my $number = $cgi->url_param('Number'); my $g1 = $cgi->url_param('b1'); my $g2 = $cgi->url_param('b2'); if ($number eq "" || $g2 eq "") { print "Please enter all the values"; } else { print "Thank You"; } }

Kindly Help. Thanx in advance.


In reply to dynamic combo box by Appy16

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.