I want to call a perl subroutine in Perl CGI. I know I need the onClick
event but not sure how to use it correctly to call "TestSub". Can anyone help?
<input type="button" value="submit" onClick="process('')">
sub TestSub {
###Do some code###
}
You can't, at least not directly.
onclick
is a client-side JavaScript function. CGI code runs on the server.
To call a Perl sub you need to:
The simple way to make that HTTP request would be to use a link or to submit a form. If you want to use JavaScript then you can assign a value to location
or use the XMLHttpRequest
object.