Submit form conditionally - JavaScript
In the long-gone days of the early Internet, having a form on
the website was tantamount to dabbling with "cutting-edge"
technologies. Intricate Perl scripts and esoteric CGI scripts
were required to process those forms and people used to suffer
bouts of cold sweat whenever there manifested a need to use web
forms. To create a form-handling script used to be in the realms
of MCAs and computer engineers. No longer is it so. The Internet
these days is replete with all sorts of form handling scripts,
and wherever you choose to host your website, or for that matter
even a web page, you can easily deploy a form handling script
and start interacting with your visitors.
As the level of interaction goes complex, you require more
complicated scripts. One way is to write a single script
containing hundreds of lines of code. The action script (that
comes within
As you can see, this form displays three radio buttons. The
objective is, send the form to a script according to the radio
button selected. Since some Javascript action needs to take
place once the Submit button is clicked, we invoke
decide_action() function through the onSubmit attribute of the