print $query->textfield(-name=>'field_name', -default=>'starting value', -size=>50, -maxlength=>80); -or-
print $query->textfield('field_name','starting value',50,80);
textfield
will return a text input field.
$value = $query->param('foo');
If you want to reset it from its initial value after the script has been called once, you can do so like this:
$query->param('foo',"I'm taking over this value!");
NEW AS OF VERSION 2.15: If you don't want the field to take on its previous value, you can force its current value by using the -override (alias -force) parameter:
print $query->textfield(-name=>'field_name', -default=>'starting value', -override=>1, -size=>50, -maxlength=>80);
JAVASCRIPTING: You can also provide -onChange, -onFocus, -onBlur and -onSelect parameters to register JavaScript event handlers. The onChange handler will be called whenever the user changes the contents of the text field. You can do text validation if you like. onFocus and onBlur are called respectively when the insertion point moves into and out of the text field. onSelect is called when the user changes the portion of the text that is selected.