in reply to Re: Re: Re: Help w/ reset
in thread Help w/ reset

I posted both the original and my altered code in my scratchpad.

Thanks for helping out. Sorry if it's a little frustrating. I'm not used to posting in forums such as these.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Help w/ reset
by bart (Canon) on Aug 04, 2003 at 01:13 UTC
    Well I've run your code from your scratchpad, and even though there is a little syntax error in the line containing the text "There are some limitations", as it doesn't end in quote + comma, it works as I expect it should do, even with a plain "reset" without command line parameters. It must be a misunderstanding on your behalf.

    You see, what this is supposed to do in a HTML form, is not clear the form, but reset it to its initial state, i.e. to the values as incorporated in the HTML. If a input element initially was empty, it should return to empty, but if it contents was "foo bar baz", then when pressing the button it should again contain "foo bar baz", and not become empty. And that is what it does, too. And this initial state is: After you encrypted the message, you should get the encrypted message again, and similar for the decrypted message.

    If you want to return to the empty state, you should simply go to the initial URL again. Or you could enforce it by using Javascript in the onclick event of a submit button:

    this.form.key.value = ""; this.form.cryptotext.value = ""; return false;
    or, embedded in a CGI.pm call, near to "reset,":
    submit('clear', "Clear", q[onclick="this.form.key.value = ''; this.for +m.cryptotext.value = ''; return false;"]),
    The last Javascript statement prevents the form submission. With Javascript disabled, the form elements won't be cleared but the form submit will happen, and the CGI should catch it and display blank form. I think you should be able to make it work using CGI::delete or CGI::delete_all, or redirect to the form's own bare URL again without parameters. I'm not too deeply experienced in CGI.pm and I'm not planning on starting now.

    Well, good luck with your project.