unescape() textarea field flashes escape character (%20..etc. ) before showing normal text.

On my HTML page, I am allowing the user to enter a 1000 character text area field.
On Submit,  I use the escape() method on the field because the data is being sent to the AS400. When returning to the page, I use an unescape() method in my onLoad function. The problem is that I get a flash of the escape characters before the noraml text appears in the textarea box. Is there anyway to prevent to this?
dyachimiakAsked:
Who is Participating?
 
AngryBinaryConnect With a Mentor Commented:
How is the textarea being populated with the escaped string? I imagine it would have to be assigned via either the scipt that generates the page (PHP, ASP, etc), or populated with javascript, since a static HTML page does not retain data after posting to a form.

If the text is being pushed into the text area via a server side script (as is most likely the case), then what is happening is the server is sending you the HTML page (escaped text and all), and your browser is waiting until the page has completed loading before firing the OnLoad event and transforming the text in the textarea. Essentially, you cannot prevent that little lag before the OnLoad event using your current method.

The behavior you should be shooting for is to transform the text on the server side, and have it served up unescaped by tweaking the back end script.

If that is not an option, then you can do some working around with javascript. Some designers like to style certain tags on a page as invisible by default (for instance, a DIV or even the entire BODY tag), and then in the OnLoad event make them visible by altering the style properties. This gives the impression that the entire page loads all at once (the drawback is if it takes a long time the user gets a little antsy and thinks the page isn't loading; a 'loading' message can be useful). If you were to make either your page or even just your textarea invisible via stylesheet, you can turn on the visibility of the hidden element once the appropriate transformations have been made in the OnLoad event and prevent that little page hiccup.

Another useful application of this technique is to style a page as disabled or hidden until every element has loaded, preventing premature clicking and ensuring certain data is available to javascript before any events get initiated by the user.

randall
0
 
ZvonkoSystems architectCommented:
The flash (or the visual representation) occures because you canvert the textarea value on some button click event.
To avoid that visual effects move the escape() statement from onClick event handler to form tag onSubmit event handler call.

0
 
dyachimiakAuthor Commented:
My onClick event actually calls a function that does the escape, sets cookies for the AS400 to know the input and output program and html page, and then does the submit. All my submits are done in the events. Can I create a hidden field that can handle 1000 characters?
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
dyachimiakAuthor Commented:
The onSubmit worked on the Form tag, but where do I unescape the text? I am now crashing while doing it in the OnLoad function.
0
 
ManishLeadCommented:
Is it giving any problem if you use hidden field?
0
 
dyachimiakAuthor Commented:
Before I use a hidden field, I need to know if I can create a hidden field that is 1000 characters in size.
I assume I can only create a hidden field with the input tag?
0
 
ManishLeadCommented:
I dont think there is size limit on hidden field. So try it.
0
 
ZvonkoSystems architectCommented:
Form fields, hidden or not hidden, do not have a transfer limit on browser side.
Only limit that I know is for input fields of type file that do have limits how much data does the web server accept. But that are most above four megabytes, perhaps ten megabytes set in the web server config.

0
 
stanscott2Commented:
Actually, <textarea> tags can be hidden, too.  Either:

<TEXTAREA NAME="comments" COLS=40 ROWS=6 style="display:none;"></TEXTAREA>

or in your CSS:

<style>
     TEXTAREA { display:none; }
</style>
0
 
AngryBinaryCommented:
Indeed, the textarea alone could be hidden. However, some may find that a suddenly appearing text box is a bit more confusing than were an entire page to appear after loading, or a visibly dilineated segment were to pop into place.

Also, if you are showing/hiding a piece of the page rather than the entire page, it may be cleaner to use 'visibility:hidden' style instead, as the element will not be invisible but space will be maintained on the page. Jumping from 'display:none' to 'display:block' or 'display:inline' could cause the rest of the page to shift, which is also visually distracting.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.