user1074593 user1074593 - 8 months ago 79
Perl Question

Perl cgi-bin auto complete

I have a very simple website that I built using Perl cgi-bin. I have one form field that displays all the application codes in my small company. Since the application list was small, I used a simple drop down list. However, with growing number of applications, the drop down is turning out to be unmanageable. Is it possible to use auto-complete for this field using Perl cgi ?

Edit : The application names are stored in a database table. I pull the application list from the database.


Alone Perl-CGI it can't do.

Try to use javascript inside your CGI script. I added the sample html and javascript below

HTML code

    <input type="text" id="someid" onkeyup="myfunc()" style="width:150px"/>
        <div id='auto_div' style="position:absolute; width:150px; height:100px;">

Javascript with AJAX call

function myfunc()
    var val = document.getElementById("someid").value;

        if (xmlhttp.readyState==4 && xmlhttp.status==200)
            var res = xmlhttp.responseText;         
            document.getElementById("auto_div").innerHTML= res;

Trigger the myfunc function on every keyup (onkeyup()) then get the value of input tag. Then pass the value from the DB connecting perl file using ajax the result of the output will store into the res variable then write the conent into the auto_div