#!/bin/sh
echo "Content-type: text/html"
echo ""
echo '<html>'
echo '<head>'
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
echo '</head>'
echo '<body><center><br><h3 align='center'>STATUS</h3></br></center>'
list=$(ls -l /tmp | grep "^d" | awk -F" " '{print $9}')
list1=$(echo $list | wc -w)
i=1
while [ $i -le $list1 ]
do
    bhai=$(echo $list | cut -d' ' -f$i)
    echo '<a href="#" onclick="myFunction(); return false;" id="movie" style="font-size: 30px; text-decoration: none; margin-left: 1cm">'$bhai'</a></font><br>'
    i=$((i+1))
done
echo '
    <script type="text/javascript">
        function myFunction () {
            var mtype = document.getElementById("movie").text;
        alert("Hi");
        alert(mtype);
        }
    </script>'
echo '</body></html>'
exit 0
This code basically displays the folders list in the directory and because of href attribute all directories becomes a link. If I click on that link it should open that directory and display folders of selected directory.
This code displays the only first directory, if I click on any link, alert gives me name of first directory only.  
 var mtype = document.getElementById("movie").text;
I am new in this, please help me in this.
Thanks in advance
 
     
    