Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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:
    onLoad="document.myForm.reset();"
    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 :)

    Cheers,
    KM

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://20656]
Approved by root
help
Chatterbox?
[stevieb]: man, when the roads are glare ice, I don't even bother going to work or out... unless I absolutely have to, or was already out in the first place
[choroba]: Tire chains are mandatory here in mountains, and the only unprepared each year are gritters
[stevieb]: I have a 3 day winter survival kit in my vehicle in the event I get snowed in in the mountains (which has happened before due to avalanches closing the roads (and once in the summer due to a massive forest fire that trapped us
[perldigious]: a handful of people in my work area did not make it, but I live pretty close and it's flat the whole way, so I didn't have any trouble. The roundabout is the worst thing I have to negotiate.
[thezip]: G'day all!
[perldigious]: Well, that and dodging the people who forget how ice works right away. :-)
[stevieb]: hey, thezip
[perldigious]: I don't miss having to drive up and down in elevation on roads that are iced over, I white knuckled gripping the steering wheel every time I had to where I used to live.
[perldigious]: So I don't envy you mountain guys if you have to drive in the winter, even with tire chains.
MidLifeXis waves.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2016-12-06 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (112 votes). Check out past polls.