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
<input type="radio" name="pick" value="Fun2" />Func2<br />
<br>
Enter a number :
<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 :
<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.