Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: how to use -nosticky in CGI?

by chargrill (Parson)
on Dec 18, 2006 at 05:33 UTC ( #590385=note: print w/replies, xml ) Need Help??


in reply to how to use -nosticky in CGI?

You're not showing this form from the button via Ajax, are you?

If you are, I've got a solution or two for you, though they're not perl.

If not, you'll have to give us a tiny self-contained example that we can run to see this behavior and help you to eliminate it.

Update: Oh yeah. If you're using FireFox with it's "remember stuff in form fields" option, then it's probably doing that for you and showing you the form with the fields filled in.



--chargrill
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)

Replies are listed 'Best First'.
Re^2: how to use -nosticky in CGI?
by Popcorn Dave (Abbot) on Dec 19, 2006 at 04:59 UTC
    I ran in to a similar problem a while back, but my data was duplicating. If the user hadn't filled out all the requested fields and the name field was John Doe, then it was coming back John DoeJohn Doe after a second submission. Might FireFox's "remember stuff" option be doing that? If so, do you have any idea of a workaround?

    This was a self referencing CGI script if that makes a difference.

    Revolution. Today, 3 O'Clock. Meet behind the monkey bars.
Re^2: how to use -nosticky in CGI?
by jck (Scribe) on Dec 18, 2006 at 14:01 UTC
    here's the basics of how i have this:
    print start_form; if ($in{'submit'} eq 'New Entry') { print table( Tr({-valign=>"TOP"}, [ td(["First Name", textfield(-name=>'firstname', -size=>80)]), td(["Last Name", textfield(-name=>'lastname', -size=>80)]) ])); } else { print table( Tr({-valign=>"TOP"}, [ td(["First Name", textfield(-name=>'firstname', -size=>80, -value=>$fi +rstname)]), td(["Last Name", textfield(-name=>'lastname', -size=>80, -value=>$last +name)]) ]));

      So, this isn't self contained, and takes a fair amount of tweaking to make work, and even then I'm not sure I can make it duplicate your behavior. As is, you've left off:

      1. #!/usr/bin/perl,
      2. use CGI qw/:standard/;,
      3. the bit of CGI code that displays the button called 'New Entry',
      4. enough data stuffed into perhaps __DATA__ to recreate the problem.

      Show us enough code that does all that (most importantly #4) that you can run in your environment, so that we can easily run it in our environments to be able to better help you.



      --chargrill
      s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)
        chargill -

        my apologies - i knew that it wasn't enough for you to really see what's going on, but what i'm working on is private information, and i didn't want to create a dummy db to demonstrate.

        what i have come up with as a workaround is to add ", -value=>'', -override=>1" to each field, as follows:

        print table( Tr({-valign=>"TOP"}, td(["First Name", textfield(-name=>'firstname', -size=>80, -value= +>'', -override=>1)]), td(["Last Name", textfield(-name=>'lastname', -size=>80, -value=>' +', -override=>1)]), td(["Address", textfield(-name=>'address1', -size=>80, -value=>'', + -override=>1)]),
        setting each value to '' doesn't do it without including the -override=>1

        so, this works, but it seems like there must be an easier, more efficient way!

        in answer to your inquiries about the rest of my code:

        1. #!/usr/bin/perl, 2. use CGI qw/:standard/;,

        the top of my script is:
        #!/usr/bin/perl use strict; use warnings; use CGI qw(:standard); use CGI::Pretty; use CGI::Carp qw(fatalsToBrowser); use DBI; my $q = new CGI;
        i've tried putting -nosticky into the use CGI statement: use CGI qw(:standard, -nosticky); which didn't clear the fields. and i also put '-nosticky' into each of the fields, again, without success (the previous field values remain). i've tried adding the line $q->delete_all(); above the code creating the form when "submit = 'New Entry'", which also doesn't work to clear the field values.
        3. the bit of CGI code that displays the button called 'New Entry',
        print submit(-name=>'submit',-value=>'New Entry'); the main conditionals that are run look like:
        %in = map { $_ => $q->param($_) } $q->param; if ($in{'submit'} ne 'New Entry') { . . $requestID = $in{'requestID'}; $sql = "SELECT title, firstname, lastname, address1, address2, city, s +tate, zipcode, zipextra, phonehome, phonework, phonecell, email, user +name, role, approved FROM members WHERE UID = $requestID"; ....code to generate table with the values from the db inserted into t +he fields... } else { ....code to generate table with empty fields... }
        4. enough data stuffed into perhaps __DATA__ to recreate the problem.

        the source of the DATA is from a sql statement, as shown above....not sure how to show you this, since it's confidential.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://590385]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2019-09-18 20:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (238 votes). Check out past polls.

    Notices?