?
Solved

Need an Idea

Posted on 2003-02-19
12
Medium Priority
?
157 Views
Last Modified: 2010-03-05
I am trying to create a web page, which will allow me to edit the web template file by loading it into the plain <textarea> web form.
Some of the templates, contain <textarea> forms, which confuses the html code for the editing page.

I just need an idea of how to edit the plain text code, containing <textarea> form inside <textarea> form.

I am planning to put this code into the template and try to edit itself by loading the editing template and then loading the same template into the <textarea> of itself.

Basically a 2-level recursion.

Thanks.
0
Comment
Question by:sstouk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 6

Author Comment

by:sstouk
ID: 7984379
More detailed explanation:
I have a file named:
configedit.cgi which has the following:

<form method="POST" action="<ScriptWebPath>">
<textarea style="width:100%; height:400" name="data">
_hfile-data-insert_
</textarea>
<input type="submit" value=" Update! " />
<input type="hidden" name="hfile" value="_htext-form-hfile_" /></td>
<input type="hidden" name="a" value="plainconfig" /></td>
</form>

When Server gets the request, it looks up the table and sees that it has to substitute the
_hfile-data-insert_ with the value from another table, determined by parameter "name="hfile" value="_htext-form-hfile_"" from the form;
It will load the template file instead  of pattern "_hfile-data-insert_"

The file I would like to edit is "configedit.cgi" which will be inserted without any substitution AsIs instead of _hfile-data-insert_  and this file is listed above.

Surely the double <textarea> tags confuses the code and the editing page does not know how to display it properly and cuts off the plain file.

Any Ideas on how to overcome this?

0
 
LVL 6

Author Comment

by:sstouk
ID: 7984405
You know, i think I can make a code for this:

<textarea style="width:100%; height:400" name="data">
_hfile-data-insert_
</textarea>

and simply substitute the whole textarea definition....
will try this.

But any other methods (possibly using a free JavaScript web-based text editor) is appriciated or any html tags, which I could easily remove later, which would allow me to edit the template from itself will bring you the points.



0
 
LVL 48

Accepted Solution

by:
Tintin earned 800 total points
ID: 7984665
What you need to do is encode the tags in the template, so it doesn't get interpretted as HTML.

With the CGI module, just use the

escapeHTML function.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:ChrisDrake
ID: 7988881
$template=~s/</&lt;/g; # escape the "<" html character
0
 
LVL 5

Expert Comment

by:Sapa
ID: 7989606
escaping '<' sign only is not enough, although MSIE allows some invalid unescaped characters in HTML. According to HTML standard, you should escape characters '<', '>', '"', and '&'. (And all another characters cannot be represented in current charset, like greek letters in iso-8859-1 charset, copyright sign, etc.). So, you need at least:

my %escapes = {
    '<' => '&lt;',
    '>' => '&gt;',
    '"' => '&quot;',
    '&' => '&amp;'
};

$filebody =~ s/([<>"&])/$escapes{$1}/g;

print '<TEXTAREA NAME=filebody>', $filebody, '</TEXTAREA>';
0
 
LVL 6

Author Comment

by:sstouk
ID: 7993335
Escaping won't do.
because I need to see exactly what I am editing.
If it will be escaped, then it will not exactly look like the HTML code inside the form for the end user.
And it should look exactly, so that the person, knowing HTML would be able to visually make changes and click Submit and those changes would apply to the page he is editing inside the form and see them visually.
No escaping, because it will be confusing.
The most I though of adding and then removing from the code was the commenting Tags to show the Form that what is inserted inside the textarea is a comment, not a code, this way the text will look exactly AsIs without any confusion, you will get the points if you could give me a working example of this,
Or the Visual JavaScript Text Editor (not html WYSIWYG editors that i was able to find plenty....). Practically all of them make their own changes to tags, if inserted inside the editor and submitted. They change the Case or remove Special tags, I could not find a single JavaScript Visual TEXT editor online, which would not substitute anything upon submission and will see the difference of what is inside the editing form is Not the code, so it won't execute it (so this code can edit itself without change);
Just point me out one such JavaScript that will work this way and you will get the points.
But commenting won't do. I want the code inside the form look exactly as it is being executed.

I understand this is not an easy question and appriciate your attention.

Thanks.
0
 

Expert Comment

by:awwaiid
ID: 7994433

Not true. Just run this:

<pre>
<textarea>&lt;textarea&gt;blah&lt;/textarea&gt;</textarea>
</pre>

through a webbrowser and you'll see that it re-renders the escaped characters for you.

(unless this thing undoes my code above, in which case it should be:

<textarea>&amp;lt;textarea&amp;gt;blah&amp;lt;/textarea&amp;gt;</textarea>
)
0
 

Expert Comment

by:awwaiid
ID: 7994436
heh. guess it didn't unquote me :)
0
 

Expert Comment

by:awwaiid
ID: 7994443
oh. in that case remove the pre tags.

sheesh
0
 
LVL 6

Author Comment

by:sstouk
ID: 7995489
I will try it and let you know.
If it is that easy - this would be the best solution.
:)
0
 
LVL 48

Expert Comment

by:Tintin
ID: 7997844
I will work, because that it the method I (and thousands of others) use.

Have faith.
0
 
LVL 6

Author Comment

by:sstouk
ID: 8005897
Thanks for an excellent and easy solution!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question