473,396 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Copying Value from a Text Area to a CGI Variable

Hey folks....i had a small issue...

i wanted to know how do i copy the value of a textarea into a CGI variable...

im able to get the Value of the Text area...

I tried this..btu its not working

$X = $cgi->param ('MYTEXTAREA');

# MYTEXTAREA is the name of the textarea.

This isnt working....

is there any other way folks..

Plz reply.....

Thanks for the Previous Replies.....
Mar 26 '07 #1
6 3629
KevinADC
4,059 Expert 2GB
that will work if you are using the CGI module and the $cgi object has been defined:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use CGI;
  3. my $cgi = CGI->new;
  4. my $x = $cgi->param('MYTEXTAREA');

It would be nice if you started responding to threads you post. Asking a question and never replying leaves people in doubt that you ever read the replies or if they were useful or not.
Mar 26 '07 #2
Thanks for a quick reply..

now before i tell u wot problem i faced after defining $cgi as u said, i would like to brief u a bit on wot im doin
i have a CGI file in which i have a textarea....now i have transferred the value of the Textarea to a variable say 'var'

now i have the code as:

my $cgi = CGI->new;
.....

$x = $cgi->new ('var'); # i tried both, with quote n without qoutes..

now the problem im facing is...

the browser shows an error message
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webadmin@plhp002.comm.mot.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


When i remove this line my $cgi = CGI->new;
this error doesnt come...

can u tell me how do i deal this situation...


n i will reply to the previous post i made...sorry for tat...

Thanks

Ravi
Mar 26 '07 #3
KevinADC
4,059 Expert 2GB
if this code does not work:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use CGI;
  3. my $cgi = CGI->new;
  4. my $x = $cgi->param('MYTEXTAREA');
most likely the CGI module is not installed (for some strange reason). Try this:


Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2. #change the line above to match your server
  3.  
  4. use strict;
  5. use CGI::Carp qw/ fatalsToBrowser /;
  6.  
  7. my $ver = '1.0';
  8. my %mods = ();
  9. my @PM = ();
  10. my @temp = ();
  11. @INC = sort {$::a cmp $::b} @INC; 
  12.  
  13. print "Content-type: text/html\n\n";
  14. print qq~<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  15. <html>
  16. <head>
  17.  <title>Perl Module List</title>
  18.  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
  19. </head>
  20. <body bgcolor="#FFFFFF"><a name="top">
  21. <div style="width:100%;background-color:#DDDDDD;text-align:center;"><h3>Perl Module Lister v$ver</h3>&copy; 2003</div>
  22. <pre>
  23. <b>Perl Version</b>: $]
  24.  
  25. <b>\@INC includes: </b>
  26. ~;
  27.  
  28. foreach(@INC){
  29.    next if ($_ eq '.' || $_ eq '..');
  30.    print "   <a href=\"#$_\">$_</a>\n";
  31. }
  32.  
  33. print "\n";
  34.  
  35. foreach(@INC){
  36.    next if ($_ eq '.' || $_ eq '..');
  37.    get_modules($_);
  38.    print_results($_);
  39.    undef %mods;
  40.    undef @PM;
  41.    undef @temp;
  42. }
  43.  
  44. print qq~\n___END OF LIST___\n
  45. </pre>
  46. <div style="width:100%;background-color:#DDDDDD;text-align:center;"><h3>Perl Module Lister v$ver</h3>&copy; 2003</div>
  47. </body></html>
  48. ~;
  49. exit(0);
  50.  
  51. sub print_results {
  52.    my ($thepath) = shift;
  53.    my $anchor = $thepath;
  54.    my $output = ();
  55.    my $nn = 0;
  56.    my @temp = sort  { lc($mods{$::a}) cmp lc($mods{$::b}) } keys %mods;
  57.    foreach my $file (@temp){
  58.       opendir(DIR,"$file");
  59.       @PM = grep /\.pm$/, readdir(DIR);
  60.       closedir(DIR);
  61.       $nn+=int(@PM);
  62.       $file =~ s/$thepath\///i;
  63.       $file =~ s/\//::/g;
  64.       $output .= "<b>  $file</b> (@{[int(@PM)]} pm files)\n";
  65.       foreach (@PM) {
  66.          s/\.pm$//;
  67.          $output .= "     $file\:\:$_\n";
  68.       }
  69.    }
  70.    my $n = int(@temp)+$nn;
  71.    print '-' x 50 . "\n<a name=\"$anchor\"></a><b>$n Modules found in $thepath</b> [<a href=\"#top\">back to top</a>]\n" . '-' x 50 . "\n" . $output;
  72. }
  73.  
  74. sub get_modules {
  75.    my ($path) = shift;
  76.    opendir(DIR,"$path");
  77.    my @dir = readdir(DIR);
  78.    closedir(DIR);
  79.    foreach (@dir) {
  80.       next if ($_ eq '.' || $_ eq '..');
  81.       if (-d "$path/$_"){
  82.          $mods{"$path/$_"} = "$path/$_";
  83.          get_modules("$path/$_");
  84.       }
  85.    }
  86.    return(%mods);
  87. }
  88.  
see what version of perl you have and what modules are listed in @INC, which is where perl knows to look for modules. The list can be quite long.
Mar 26 '07 #4
hey i think im jus trying different things but not getting it...

ok let me tell u wot im trying to do, so u can give me some idea...

I have some Text on the Browser. I want to Edit it.and after editing, the edited text shud be saved. Thats all i want to do.


now wot i thought n wot i have been trying till now was, i will have a variable (say 'name') which will contain the text. this variable will b in a file (.pl file)

first, this variable will be taken into a TEXTAREA, there the editing will b done and after that the new text(i.e. the edited text) will be saved in the same variable 'name'.

now the problem is, when i try to take the value from the textarea to the variable...facing this problem...

now is there any way of doing this thing?...bcoz of less knowledge on CGI/PERL, i dint come across anything else...though i tried few things with TEXTAREA..coz i think editing can be done only using tat...
if there is any other way lemme know......i will try tat...



Thanks

Ravi
Mar 27 '07 #5
KevinADC
4,059 Expert 2GB
http://perldoc.perl.org/CGI.html
Mar 27 '07 #6
Thats a kool link kevin....

once i get a solution to my problem,i will post back
thanks...

Ravi
Mar 27 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns...
7
by: Cues Plus | last post by:
Hello, I have a simple form text area for people to add comments in. The problem is that using the standard <TEXT AREA NAME="comments" ROWS=4 COLS=35></TEXT AREA> Allows people to put in...
10
by: David Rasmussen | last post by:
If I have this struct S { int arr; }; and I do this: S s1,s2;
8
by: PerryC | last post by:
I want to be able to accomplish this, please help: When click on the DOB field, a ActiveX Calender popup and the user choose a date, the value is automatically refreshed in the DOB field in the...
10
by: Cocy | last post by:
Hi, This might be a sort of FAQ, but I don't see why, so I would someone help me to understand what's wrong? I've just created following code which wold trim white space(s) in a (given) string....
4
by: Jake Barnes | last post by:
I wanted to teach myself AJAX this weekend so I sat down with Stuart Landgridge's book and I started to play around. I came up with a little page that you can add text and images to. You can see it...
1
by: satish2112 | last post by:
Hi, I have a text-area which contains values from mysql database and 2 buttons, Edit and Update. When I click on the Edit button, I can edit the text-area (initially non-editable). After this,...
5
by: laredotornado | last post by:
Hi, If my variable contains var v = "Hi<BR/>there<BR/>"; and attempt to set the value of my textarea like so: dojo.byId("appEditForm:txtDesc").value = v;
2
by: raylopez99 | last post by:
Beware newbies: I spent a day before I figured this out: copying a bitmap (image) file to file is not quite like copying a text file--you have to do some tricks (see below), like using a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.