Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Browser Manipulation

by vtprogrammer (Friar)
on Jun 30, 2000 at 23:26 UTC ( #20656=perlquestion: print w/replies, xml ) Need Help??
vtprogrammer has asked for the wisdom of the Perl Monks concerning the following question:

IS there any way in PERL to reset a form when a user hits the BACK button on their browser or any button for that matter?

Replies are listed 'Best First'.
Re: Browser Manipulation
by Zoogie (Curate) on Jul 01, 2000 at 03:13 UTC
    As chromatic said, this is really a client-side issue. Probably the easiest way to achieve this is to use client-side JavaScript, not Perl. Just add:
    to your <body> tag (replace myForm with the name of your form), and you should be set (tested in Netscape, haven't tried IE).

    - Zoogie

Re: Browser Manipulation
by chromatic (Archbishop) on Jun 30, 2000 at 23:45 UTC
    No, not really. That's a client-side issue. Unless you have PerlScript running in the browser, your only approach is to add a Reset button to a form: <input type="reset" value="Reset">
    Even that's an HTML approach.
(jeffa) Re: Browser Manipulation
by jeffa (Bishop) on Jul 01, 2000 at 03:12 UTC
    I can't belive am fixing to post a Javascript solution. Maybe I'll get shot, but since it looks like it can't be done in Perl, here goes . . .

    First off, this is only for one text box.

    <body onLoad='document.formFoo.txtFoo.value=""'> <form name="formFoo"> <input type=text name="txtFoo"> </form> </body>
    It's a hack, but hey . . .

    The concept is to set the controls to a default value when the document is loaded. If you want to clear a text box, just use the empty string. For radio buttons and check boxes, you have to turn them on/off explicitly.

    This could get nasty if you have a lot of controls to 'reset'

    UPDATE: see Zoogie's reply below ->

      I agree all the way. Perl is wonderful for server-side programming but if you want to do something that directly involves client side controls, have Perl generate the JavaScript (or other native client side scripts) code as part of the document.
      Just be aware that the client can see everything once it is loaded into the browser (don't put anything there that you don't want others to see)....... IMHO
Re: Browser Manipulation
by KM (Priest) on Jun 30, 2000 at 23:53 UTC
    You can try by setting the pages for no cache, and for expiring. I believe there are some Apache and mod_perl ways to do this. Don't quote me though :)


Re: Browser Manipulation
by toadi (Chaplain) on Jul 01, 2000 at 23:49 UTC
    The best solution is already suggested by chromatic. That's html solution...
    <input type="reset" value="Reset">

    Dump javascript...only program javascript when there's no alternative.
    My opinions may have changed,
    but not the fact that I am right

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://20656]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-05-26 07:04 GMT
Find Nodes?
    Voting Booth?