troubleshooting Question

Need Classic ASP technique to place focus on first textbox ONLY when page first loaded, NOT on a postback

Avatar of bshelby777
bshelby777Flag for United States of America asked on
JavaScriptASPWeb Applications
9 Comments2 Solutions2955 ViewsLast Modified:
I have a Classic ASP application (not ASP.NET) in which, if there are errors found when the page is submitted, focus is placed on the first textbox in error via Javascript.  This all works perfectly.  However, when the page is displayed for the FIRST TIME, the focus isn't on the first text textbox (the area code).  If I add the following code:

<body onload="frmGetAcct.areacode.focus();">

to put the focus on the first textbox when the page first displays, the focus does indeed go to the first text box on the page.  The problem is that it goes there every time the page re-displays, so my javascript focus on any field in error is lost - it positions to the field in error, then refreshes and positions to the first field.

Basically, I need the ASP equivalent of ASP.NET's

If Page.IsPostBack=True

to see if this is the first time the page has loaded or if it is reloading.  Is there a way to do that in Classic ASP?

Note: II need the solution in Classic ASP and/or Javascript only.  This is just a "would be nice" issue on an old website and I don't have the cycles to use/learn a different tool (PHP, etc.) right now.  Thanks.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros