Much cleaner way, also work.
sub HandleRequest
{
$MyString="Fred";
$co->param(-name=>MyArea,v
}
Main Topics
Browse All TopicsI think I may under a misapprehension as to what CGI is all about.
I have debugged and debugged my perl software down to a point wherby it is a simple item that is going wrong. (The bones of the code are below)
Why does this code not give me "Fred" in my text area? I know that the correct path is being followed when I press the button as the printing of the string "$MyString" at the end of the code gives me the correct printout - it just doesn't refresh my text area.
I was under the apprehension that if I send a whole new web page, this would replace what was on the screen but it doesn't seem to.
What am I missing when it comes to CGI?
How do I refresh what is on my screen?
Many thanks from a CGI beginner.
use CGI;
$co = new CGI;
if ( ! $co->param())
{
$MyString = "Hello";
DrawPage();
}
else
{
if ($co->param('MyButton') ne "")
{
HandleRequest();
DrawPage();
}
}
sub HandleRequest
{
$MyString="Fred";
}
sub DrawPage
{
print
$co->header(),
$co->start_html
(
),
$co->start_form(),
$co->textarea
(
-readonly=>'true',
-name=>'MyArea',
-default=>$MyString,
-rows=>10,
-columns=>45
),
$co->submit
(
-name=>'MyButton',
-value=>'Button'
),
$co->end_form,
"$MyString",
$co->end_html;
}
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I found a solution, but not a root cause. To solve this problem, you need to add one more parameter into your textarea function call:
$co->textarea
(
-readonly=>'true',
-name=>'MyArea',
-default=>$MyString,
-rows=>10,
-columns=>45,
-override=>1
),
This is where I read about it:
http://stein.cshl.org/WWW/
It's *not* something that shows up in the HTML source for some reason. I'm not exactly sure what's happening behind the scenes, but if I find out, I'll pass word along. Another tip from a former beginner -- use strict; in every script you write and explicitly declare every variable you use. It will save you countless headaches. Here's how I'd write your script:
use strict;
use CGI;
use CGI::Pretty;
# CGI::Pretty makes the HTML source readable for debugging
my $co = new CGI;
my $MyString = "";
if (! $co->param()) {
$MyString = "Hello";
DrawPage();
}
elsif ($co->param('MyButton') ne "") {
HandleRequest();
DrawPage();
}
sub HandleRequest {
$MyString = "Fred";
}
sub DrawPage {
print $co->header(),
$co->start_html(),
$co->start_form(),
$co->textarea(
-readonly=>'true',
-name=>'MyArea',
-default=>$MyString,
-rows=>10,
-columns=>45
-override=>1),
$co->submit(-name=>'MyButt
$co->end_form(),
$co->end_html;
}
VEngineer
you're a star!
The fix works and everything is now hunky-dory!
Before I close this question, one little point please.
The form that this whole question relates to accesses its
own data files under my cgi-bin directory.
No-one else (apart from me uploading and downloading those data files) can see the data files.
What permissions do I need to set on the data files?
DO I need to give NO access to everyone else except the owner?
Lots of people will be accessing the data files (via the program) and they will require to read from and write data to the files which is only done VIA THE PROGRAM.
Does this affect the access permissions?
Business Accounts
Answer for Membership
by: samriPosted on 2002-07-04 at 02:34:19ID: 7129472
Strange too.
value=Fred ), then it works.
alue=>Anot her);
Added $MyString in the title, it appears to be Fred.
$co->start_html
(-title=>$MyString
),
Somehow, it the textbox, it's Hello again.
If we change the $co->param(-name->MyArea,-
-- modified sub.
sub HandleRequest
{
$MyString="Fred";
$co->param(-name=>MyArea,v
}
I still can't explain what is happening. I would have suspected that the Assignment is not happening, but the title page show the Fred.