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

OK, this is leading nowhere. We need to see some code before anybody will be able to get you any further. I do believe some confusion between the built-in reset and the button on the form, and the stickiness of CGI.pm is basically the cause of your problems, but that's as far as my ESP goes.

Can you put your faulty demo script up some web site, preferably both as a "working" script, and the source? If that's not possible, at least put the source in your scratchpad, between "<code>" and "</code>" tags. You may /msg me when that's happened, or post another reply.

Replies are listed 'Best First'.
Re: Re: Re: Re: Help w/ reset
by bobasinbob (Initiate) on Aug 01, 2003 at 02:17 UTC
    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.
      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.

Re: Re: Re: Re: Help w/ reset
by bobasinbob (Initiate) on Aug 02, 2003 at 00:12 UTC
    I thought I replied to this last night but I guess I didn't, sorry.

    I copied the original code and my code into my scratchpad.