aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Delay while I type characters in the text box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Delay while I type characters in the text box" Watch "Delay while I type characters in the text box" New topic
Author

Delay while I type characters in the text box

Naveen Morrise
Greenhorn

Joined: Jun 06, 2006
Posts: 25
Need help in how to code in such a way that, I should get all the elements of the xml document initially when the page first loads (or something like that) and store the elements in some JavaScript data structure. So that, for subsequent access I can access from that data structure rather than invoking the xml parsing api every time.
[ June 06, 2006: Message edited by: Bear Bibeault ]

Naveen
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
AJAX?


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61421
    
  67

"Mike Corleone", you have previously been warned on one or more occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it prior to your next post.

Be aware that accounts with invalid display names are removed.

bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61421
    
  67

Naveen, your subject line and your topic seem to have little to do with each other. Please clarify.
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
Apologies. I have now changed my display name.
[ June 06, 2006: Message edited by: Lynette Dawson ]
Naveen Morrise
Greenhorn

Joined: Jun 06, 2006
Posts: 25
I had a JSP page where <form id="frmCreateMain" name="frmCreateMain" method="post" action="matchToPreexisting.jsp" target="addrstand"> has call to the database, which is causing the delay in sending a XML response back which is getting parsed on everykey stroke which is time consuming. So, some how I need to get this delay reduced.

Here the scenario works like below:

The front end is the JSP Page that is displayed to the normal user.

Any thing that is displayed on the GUI, that might be either label or the text box or might be any thing is being populated from XML file.

The underneath XSL file is generating the HTML file based on the XML at the GUI.

And my understanding of the code is correct and sure.

So, if some one can help me in giving me the idea why in the GUI it displays characters or numbers after a while. The amount of delay is significant and can be seen even by the normal user. This is the reason only, why I am thinking how to code in such a way that, getting all the elements of the xml document initially when the page first loads (or something like that) and store the elements in CustomerCreate JavaScript data structure. So that, for subsequent access you can access from that data structure rather than invoking the xml parsing api every time .
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61421
    
  67

You're submitting the form on every keystroke?
Naveen Morrise
Greenhorn

Joined: Jun 06, 2006
Posts: 25
Yes you are right
Naveen Morrise
Greenhorn

Joined: Jun 06, 2006
Posts: 25
it is coded like that. I am new to the team. But the one who developed did like that.

and I need how to improve the code.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you use the onchange event trigger instead of one of the keystroke events, the form won't be submitted until the user leaves the given field.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Naveen Morrise
Greenhorn

Joined: Jun 06, 2006
Posts: 25
I have onkeyup function right now

fName.attachEvent('onkeyup',initName);

So, do I have to change it or not. Please correct me.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Think about when you want the event to be fired.

If you want it to happen with each keystroke and don't mind waiting, leave it as it is. If you don't want it fired until the user is done working with the given field, use the onchange or onblur event triggers instead.
Naveen Morrise
Greenhorn

Joined: Jun 06, 2006
Posts: 25
So, Can I use

fName.attachEvent('onChange',initName);
or
fName.attachEvent('onBlur',initName);

lines of code for my purpose
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61421
    
  67

As this has become more about client-side code than JSP, I've moved this to the HTML forum.
Naveen Morrise
Greenhorn

Joined: Jun 06, 2006
Posts: 25
Can any one help in this regards by looking the above series of forum
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Why don't you search Google for Ajax autocomplete and see if that helps give you an idea.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Delay while I type characters in the text box