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

Fellow Monks,

Short and simple question this, I have a couple of perl cgi scripts running, but my manager wants to change the look and feel of the entire website. I've created a couple of gifs for my new buttons. Trouble is, I can't figure out how to use these buttons with the reset feature. I thought this code might work

$co->reset(-name=>'Reset button',-src=>'/reset.gif'),
but it just produces the standard grey button. Obviously an image button produces the button I would like:
$co->image_button(-name=>'Reset button',-src=>'/reset.gif'),
How can I make this reset the form (if possible).
My thanks for any advice offered

Jonathan

Replies are listed 'Best First'.
•Re: cgi.pm reset button question
by merlyn (Sage) on Apr 09, 2004 at 10:30 UTC
    The HTML specification does not have a mechanism for a "reset" button to have an image graphic. Thus, any solution offered you here is likely to be non-portable.

    Please also consider the advice of experts that a "reset" button that is likely in any way to be confused with a "submit" button is also very very user-unfriendly and dangerous. In fact, I can't recall seeing a "reset" button on any recently designed big-boys web pages, so apparently the advice is being followed.

    "Reset buttons are soooo mid-90's". {grin}

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Actually, you've made me rethink the whole issue. Your advice is sound and makes complete sense, I'm gonna get rid of the reset buttons.

      Many Thanks,
      Jonathan

      yeah....the whole idea of a reset button was someone thinking not quite right. why would anyone in their right mind answer half a form or more wrongly, to require a reset button? good riddens reset button idea.
        You're not considering all of the different ways in which a form can be used. Not all forms are simple "type in your name and address" sorts of things. The form might be displaying some complex data that the user is expected to edit, and a Reset button can save you a roundtrip to the server (and therefore be a lot faster, and improve the user's perception of the responsiveness of the page or application).

        Since I don't know what sort of form the original question is regarding, I won't venture to guess whether a Reset button makes sense in this case.

        Linda

Re: cgi.pm reset button question
by bassplayer (Monsignor) on Apr 09, 2004 at 13:31 UTC
    Glad you are rethinking this. Just in case anyone has a PHB who won't listen to reason, I believe that this can be done with JavaScript, using a regular button, the onclick event handler, and the JavaScript reset() function. As merlyn mentioned, there may be compatibility issues.

    bassplayer

Re: cgi.pm reset button question
by chanio (Priest) on Apr 09, 2004 at 21:07 UTC
    Why not calling the cgi script again as a way of resetting?

    Your call should be the same way that you did when creating that form. It has to be a better reset button. Because, instead of erasing all the data, it turns your form into its primitive state. Perhaps, with important data in it.