Solved

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

Posted on 2007-03-30
10
1,326 Views
Last Modified: 2008-01-09
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?
0
Comment
Question by:dyachimiak
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 18823141
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
 

Author Comment

by:dyachimiak
ID: 18823276
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
 

Author Comment

by:dyachimiak
ID: 18823464
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
 
LVL 11

Expert Comment

by:Manish
ID: 18823790
Is it giving any problem if you use hidden field?
0
 

Author Comment

by:dyachimiak
ID: 18823845
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 11

Expert Comment

by:Manish
ID: 18824127
I dont think there is size limit on hidden field. So try it.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 18824763
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
 
LVL 13

Accepted Solution

by:
AngryBinary earned 500 total points
ID: 18826547
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
 
LVL 15

Expert Comment

by:stanscott2
ID: 18827315
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
 
LVL 13

Expert Comment

by:AngryBinary
ID: 18827703
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now