in reply to CGI.pm input vs textfield

You need to add force => 1 to the textfield.

input is one of CGI.pm's "dumb" tag creation methods. None of the attributes you pass ("type", "name", "value") have any special meaning -- it just generates the HTML blindly. You can even write things like this: it's all the same to the input method:

input({ foo => "bar", blok => "head" }); # <input foo="bar" blok="head" />
textfield, on the other hand, is a "smart" tag creation method with special logic. Some attributes you pass in now have special meaning. The kicker is that it inteprets the "value" attribute as merely a default (In fact, you can use "default" as an alias for "value"). So unless you tell it otherwise (with force => 1), it will act as a "sticky" form and take the new value for that field from the query string.

blokhead

Replies are listed 'Best First'.
Re^2: CGI.pm input vs textfield
by ishnid (Monk) on Jun 24, 2004 at 13:18 UTC

    If you want to turn off sticky forms on all fields (as setting force => 1 for each field can get irritating if your form is large), you can do it in the use statement

    use CGI qw(-no_xhtml :standard *table *Tr -nosticky);

      Tried -nosticky it makes no difference. Now force => 1 does make it work "as expected". To me, force => 1 needs to be a default behaviour. Thanks for your good advice.