#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    4
    Rep Power
    0

    javascript & perl


    I am writing text to a file from a form, with a text area, and then displaying it back to a text area, It just so happens that some of the files that are being viewed in the text area are html files, when a html file is printed to the text area, the javascript is left out, is there a way to fix this so that the whole file displays correctly?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    4
    Rep Power
    0
    ok... to further elaborate(i noticed i wasnt very descriptive about my problem)
    i am making a text editor, that works from a web site, when i edit a file somtimes it works and somtimes it dont..... heres the script...

    require "subparseform.lib";
    &Parse_Form;

    $CGI::POST_MAX = 512 * 1024; # limit posts to 512K max
    use diagnostics;
    use strict;
    no strict "vars";

    print "Content-type:text/html\n\n";

    my $fileName = $formdata{'file'};

    open (htmlFILE, "../htdocs/$fileName") || fileError();
    my @webContent = <htmlFILE>;
    close (htmlFILE);

    $charCount = 0;
    $pageCount = 1;

    foreach $dataline(@webContent){

    $charCount = $charCount + length ($dataline);

    if( $charCount >= 30001 )
    {

    $pageCount++;
    $totalChars = $totalChars + $charCount;
    $charCount = 0;
    }
    }
    if( $pageCount == 1 )
    {
    open (htmlFILE, "../htdocs/$fileName") || fileError();
    my @webContent = <htmlFILE>;
    close (htmlFILE);
    print "<form action=webEdit2.pl method=post target=workSpace>";
    print "<p align=center>Currently working with: $fileName<br>\n";
    print "File length: $charCount characters<br>\n";
    print "Numer of Pages: $pageCount\n";
    print "<br><input type=submit value='Save to temp file'>";
    print "<input type=hidden name=fileName value=$fileName>";
    print "<textarea name=webEditor rows=10 cols=600>";
    foreach my $line(@webContent) {
    chomp $line;
    print "$line";
    }
    print "</textarea></form>";

    }


    why are some files working correctly, and others not?
    Last edited by damion; August 6th, 2003 at 10:45 PM.
  4. #3
  5. Perl Monkey
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    May 2003
    Location
    the far end of town where the Grickle-grass grows
    Posts
    1,860
    Rep Power
    109
    Could try escaping the html before printing.
    Code:
    use CGI 'escapeHTML';
    foreach my $line(@webContent) { 
      chomp $line;
      print escapeHTML($line);
    }
    And I don't think I follow your code. The first thing you print is a manual content-type header, then the next thing you print are closing tags for a form and textbox?
    Last edited by icrf; August 6th, 2003 at 07:54 PM.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    4
    Rep Power
    0
    tried it, thx... but it didnt work

    if i remove the chomp function, it prints some files correctly, but removes lines from others or adds a space between lines, if i leave the chomp function it prints some files correctly, but runs the file all together instead of displaying it correctly in the text area
    Last edited by damion; August 6th, 2003 at 08:01 PM.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    4
    Rep Power
    0
    i just saw what you were talking about *feels stupid....
    that was a result of a messed up copy and paste and i fixed it in the code above as well as in my code but the problem still exists
    Last edited by damion; August 6th, 2003 at 10:47 PM.

IMN logo majestic logo threadwatch logo seochat tools logo