$select=$query->param('Select');
$submit=$query->param('Submit');
if ($select ne "") {
&view;
}
else {
&showdir;
}
sub showdir {
...
.... code stuff
.....
......function for javascript
</head>
<script language="JavaScript">
function lookup (tform,DEVICE) {
tform.Select.value = DEVICE;
tform.Sumbit;
return false;
}
</script>
.. stuff collecting text in arrays @c1 @c2 thru @c10
.. printing out in 5 col table
...
print "<input type=\"hidden\" name=\"Select\" value=\"\">";
#eventually I want to place the below print in a
#foreach loop to print out each $_ of arrays
#@c1 thru @c10
print "<a href=# onclick=\"return lookup(pr_mngr,'DEVICE');\">DEVICE</a>";
print "<table border=\"0\" width=\"100%\">\n";
print "<tr>\n";
...
...
....
...
}#close sub
sub view {
trying to get variable in here to use for other coding purpose.
}#close sub
You have a script. When you launch it, the server produces some response in a form of webpage (dynamic). This page contains a few HTML elements with some blah-blah-blah..., along with the form (or a few forms), of course. Any form contains some options to select from (select box, or checkboxes, or radio buttons,...) ot a simple text field(s) you can enter any word(s). Submit button as well (or you may use .sibmit() method).
When you push this button (or use .submit() method) you send some value(s) to the script (the name should be in <form action="url_of_some_script.cgi"...> ; if action is empty, this means the same script will be used).
So, the script must be able to process the own request (form variables).
You must have a procedure to process'em. E.g. sub parse_form {...} (there are a lot of, but all are the same in general).
Somewhere in the beginning of the script you place something like this :
#!shebang
my(%form_hash) = &parse_form();
if($form_hash{'select'}) {
do something with this value
}
...the rest of the code
...
sub parse_form {
...code
}
...
1;
As for the function call to trigger .submit() method, you may place it in any appropriate event handler of form element you use to choose the value. E.g. <select .... onclick="lookup(this.value)"...>