bobasinbob has asked for the wisdom of the Perl Monks concerning the following question:

I don't pretend to know Perl (Perl-CGI) that well but I can do a little here and there but this has me baffled. Over at: http://www.carumba.org/hacks/pontifex/pontifex.cgi they have a code and their rest button works but as soon as I try it on my own site the reset button doesn't reset the data. I'm unaware of how to place a reset button in an existing script so if someone can help me out with this problem I'd be greatly appreciated. The code that's offered only has this referring to reset: "

", submit('crypt','Encrypt'), " ", submit('crypt','Decrypt'), " ", reset, end_form, "";

Replies are listed 'Best First'.
Re: Help w/ reset
by sauoq (Abbot) on Jul 29, 2003 at 19:38 UTC

    The reset button is handled by your browser. There is no communication with the server when you hit reset. You should look at the source of the page when it is served from your site to determine what is wrong.

    -sauoq
    "My two cents aren't worth a dime.";
    
      After a few hours last night I realize I'm not any closer. Something's missing.
      Does anyone have any ideas?
Re: Help w/ reset
by bart (Canon) on Jul 29, 2003 at 23:34 UTC
    Perhaps there is a confusion with the built-in keyword "reset". Try writing it with a different case, like "Reset".

    Oh, and a "reset" button won't clear the fields, if they have a default value. Instead, it will set them back to the value the initially were. In the HTML source, you can see that by looking at the "value" attribute.

      I think I'm almost on the right track. I added: reset ('Reset', 'a-z'), to the script and initially it will reset. Once I either hit "Encrypt" or "Decrypt" it no longer will reset (or clear) Any ideas?
      I thought I was getting closer but realize I can only reset it once and that's before I hit the "Encrypt" or "Decrypt" button

      Any ideas on why that would be?
        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.

Re: Help w/ reset
by derby (Abbot) on Jul 29, 2003 at 20:25 UTC
    That little snippet of code looks like its using CGI to output HTML. That should produce HTML like this:

    <input type="reset" />

    What does the produced HTML look like?

    -derby

      The produced HTML from the existing reset just encrypts or decrypts the code again and doesn't blank everything out. On the Caruma website it resets itself (when running it from the link I mentioned). It looks like they're using some type of custom HTML that they're drawing from so when running the code off their CGI extension it prints everything out on the same page. Unfortunately with the code they supplied I'm limited in my knowledge of how to output it to a HTML page so I can only run it off the CGI script directly. If I figured out how to run the code from a form type HTML page and have the CGI throw the output to that then I'd have it made.