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 :
and posted this in the html for two submit buttons:<script type="text/javascript"> var mysample = ''; function setval(varval) { mysample= varval; alert(mysample); } </script>
Also, I added a hidden input to pass the parameter to CGI :<input type="submit" value="Add Entry" onclick="setval(1)" /> <input type="submit" value="search" onclick="setval(2)" />
However, on running the html file, it is not passing the mysample variable value to the CGI. Any ideas?<td align="left"><input type="hidden" name="mysample" size="15" maxlen +gth="50"></td>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Pass variable values from HTML to CGI using "onclick"
by poj (Abbot) on Jul 05, 2013 at 21:17 UTC | |
by newtoperl101 (Novice) on Jul 05, 2013 at 21:29 UTC | |
by poj (Abbot) on Jul 05, 2013 at 21:36 UTC | |
by newtoperl101 (Novice) on Jul 05, 2013 at 21:48 UTC | |
Re: Pass variable values from HTML to CGI using "onclick"
by Anonymous Monk on Jul 06, 2013 at 19:42 UTC | |
Re: Pass variable values from HTML to CGI using "onclick"
by sundialsvc4 (Abbot) on Jul 07, 2013 at 15:31 UTC |
Back to
Seekers of Perl Wisdom