Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cgi.pm nosticky not working

Status
Not open for further replies.

philote

MIS
Oct 2, 2003
861
US
It appears as though my fields, most importantly some hidden fields, are being 'sticky' although I specified the nosticky pragma as follows:
Code:
use CGI qw(-nosticky);



Kevin
A+, Network+, MCP
 
Does anyone have any ideas on this? I just made sure I have the latest version (3.00) of CGI.pm but I'm still having this problem.

Kevin
A+, Network+, MCP
 
I'm bumping this post because this is an annoying (though minor) problem.

Kevin
A+, Network+, MCP
 
Kevin,

Can you give us a specific example, are you passing hiddne fields in the form?

--Paul

 
I don't really have a specific example handy because this happens on every field I use: hidden, text, etc. I can find or make up an example if you need to see it. I can get around this by specifying 'override' for each field but 'nosticky' is supposed to take care of that.

Kevin
A+, Network+, MCP
 
Kevin,

It's been a while, forgive me, but what do you need the nosticky pragma for, and how are you implmenting it.

Is it possible that the use of 'nosticky' isn't being picked up by the CGI module, because of incomplete syntax?

--Paul
 
According to the manual for cgi.pm
Code:
use CGI qw(-nosticky);
causes cgi.pm to not have sticky fields.
That's all I'm doing to implement it. This should allow me to avoid specifying
Code:
-override=>1
for all the fields.

Kevin
A+, Network+, MCP
 
Well, I've tried this:
Code:
use CGI qw(:standard -nosticky);
which should be the same thing and it doesn't work.

Kevin
A+, Network+, MCP
 
Yea, just trying anything at this point since it *should* work either way but its not.

 
Thanks for the help, unfortunately it doesn't work that way either.

I peeked at the code for cgi.pm and found out one thing I was probably doing wrong. The nosticky flag comes into play in the endform sub and for some reason I was just printing the <form> and </form> tags instead of calling the cgi routines for this. However, using endform hasn't fixed my problem. Any other ideas? I tried messing with the nosticky function in cgi.pm to set or get the NOSTICKY flag, but I don't think I'm passing the right parameters to it to set the flag. Without parameters, which I believe should cause it to return the value of the flag, it returns a 0. So maybe the flag's not getting set? Is there a better way to tell?

Kevin
A+, Network+, MCP
 
Are you using startform as well? You may need to use both for the sticky flag to take effect.
 
Yep, I've now got starform and endform, and everythings still sticky :-(
The more time that goes by without a solution the less I care about finding one. I guess it's not that big a deal to remember to put -override=>1 in all my fields.
BUT, this is still really annoying because it's supposed to work.[evil]
The other thing that gets me is that I haven't found anyone else having this problem. Therefore I suspect its either something I'm doing wrong or no one else bothers to use nosticky.

Kevin
A+, Network+, MCP
 
Kevin,

Put up some sample code so we can see how you're implmenting it

--Paul
 
Ok, here's some samples...

Creating an instance of the cgi object:
Code:
use CGI qw(-nosticky);
my $cgi = new CGI;
Getting parameters being passed into the script:
Code:
my $item = $cgi->param('item');
my $quantity = $cgi->param('quantity');
Printing the form:
Code:
print $cgi->startform();
...
print $cgi->hidden(-name=>'item', -value=>$item);
print $cgi->hidden(-name=>'size', -value=>$size);
...
print $cgi->submit(-name=>'action', -value=>'Update');
print $cgi->endform();

As you can tell, this form submits to itself. It's a shopping cart script, so the user can update the quantity of each item in their cart. The item number is a hidden field, as is the size of the item. The problem is that the first item whose quantity is updated gets 'stuck'. So that the next time the hidden fields are written the name and size are from that first item that was updated.

Again, I can make sure I write the hidden fields like:
Code:
print $cgi->hidden(-name=>'item', -value=>$item, -override=>1);
but I'd rather just be able to specify nosticky and be done with it.

Thanks again for everyone's help thus far.

Kevin
A+, Network+, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top