textfield problem drove me crazy

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I was going crazy over this stupid thing because the second text field
wouldn't display $a.  I had to put in -force=>1 for it to work.  Is
that normal?  I thought I had a bad, but Dr. Stein's examples
ran fine on my system.  I scrutinized his simple examples so closely
and couldn't find what I was doing wrong.  Of course, the examples I
was looking at didn't involve displaying a result in a textfield.

use CGI ':standard';
$a = "";
if (param)
        @a = param('horse');
        $a = join (',',@a);
        $b = param('tuna');
        $c = param('cow');
        $a = "$a, $b, $c.";
print header;
print start_html();
print start_form;


print end_form,end_html;

Re: textfield problem drove me crazy

wana wrote:
Quoted text here. Click to load it
it may have something to do with what the passed parameters are (try
dumping Vars() somewhere), but...

1) your variable names aren't very helpful
2) you haven't reduced this problem to its smallest possible size before
3) you haven't produced any output for us to scrutinize

so there isn't a lot for us to go on.


Re: textfield problem drove me crazy (wana) wrote:
Quoted text here. Click to load it

I assume what you mean by that is that the 2nd time the cgi is invoked,
it returns "chicken" with the values that were submitted after the first
time the script was invoked, rather than the edited values you think it
should have.  Right?

Quoted text here. Click to load it

Yes.  Without 'force' or some equivalent, when CGI regenerates the same
form that was just submitted, it uses the values that that parameter
currently has (i.e. It only uses your default value if there is no already
existing value in that parameter).

As an alternative to using force, you could just set the parameter to what
you want to be sometime before you print the form element:



-------------------- http://NewsReader.Com / --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB

Re: textfield problem drove me crazy wrote in message
Quoted text here. Click to load it

Thanks!  I like your way better than mine.  Sorry about the oversized
example.  I trimmed it:

use CGI ':standard';
$a = "";
if (param)
        $a = param('cow');
print header;
print start_html, start_form,
,submit(), end_form,end_html;

Site Timeline