http://www.perlmonks.org?node_id=1042795

newtoperl101 has asked for the wisdom of the Perl Monks concerning the following question:

Hello PerlMonks. I have a HTML file that has a form with different text input blocks (Add/Search/Delete)each with different submit buttons. There is a CGI script which takes all text box parameters from the HTML file. However, for each submit button, with "onclick" I want to pass a value(0,1,2 etc) to it so that I can have a switch case 1-Add, 2-Search etc in the CGI script for relevant Add/Search/Delete subroutines. Inside the html file I created a little javascript function as follows :

<script type="text/javascript"> var mysample = ''; function setval(varval) { mysample= varval; alert(mysample); } </script>
and posted this in the html for two submit buttons:
<input type="submit" value="Add Entry" onclick="setval(1)" /> <input type="submit" value="search" onclick="setval(2)" />
Also, I added a hidden input to pass the parameter to CGI :
<td align="left"><input type="hidden" name="mysample" size="15" maxlen +gth="50"></td>
However, on running the html file, it is not passing the mysample variable value to the CGI. Any ideas?