One problem is when you click the submit button.
The javascript method writes the result AFTER the form has been submited.
For example if you write
when you click the link it will go to a1.
Replace the submit button with a normal one (type="button").
Try to send the form from javascript after you execute "crypt()". There is a "submit()" method for forms.
Other errors can be present but I think this is the problem.
Try to debug the code. Place alerts before and after every line from the function crypt and see if it gets there.
I recommend Firebug. It's a great tool for firefox that helps you with the javascript errors.