Solved

ASP Focus problem

Posted on 2016-11-08
3
76 Views
Last Modified: 2016-11-21
I have an input box "DispatchNote", if this is blank I want to set the focus to it, if it is not blank I want to set the focus to SerialNo. I have tried this but it is not working: -
</head>
<% 
if Dnote = "" or isnull(Dnote) then
%>
<body bgcolor="#A1FC03" text="#000000">
<form name="AddSerials" action="Serials.asp" method="post" defaultfocus ="DispatchNote">  
<% 
Else
%>
<body bgcolor="#E5EC09" text="#000000">
<form name="AddSerials" action="Serials.asp" method="post" defaultfocus ="SerialNo">  
<% 
end if
%>

Open in new window

Can anyone help?
0
Comment
Question by:HKFuey
[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
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 41879086
the defaultfocus attribute can only be used with .NET, not classic asp. you can use straight up JS to accomplish what you want:

<script type="text/javascript">
     function setFocus( val ){
          if( val == '' ||val == nul )
              document.getElementById('DispatchNote').focus();
          else
              document.getElementById('SerialNo').focus();
     }
</script>
</head>
<body bgcolor="#A1FC03" text="#000000" onload='setFocus()'>
<form name="AddSerials" action="Serials.asp" method="post">  

rest of html down here

Open in new window


this assumes your text fields have IDs labelled DispatchNote and SerialNo
0
 

Author Comment

by:HKFuey
ID: 41879093
Thanks, Big Monty. Going home now will try tomorrow.
0
 

Author Closing Comment

by:HKFuey
ID: 41895575
Thank you.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XML and version of MS XML Dom Document versions 5 43
asp classic find word in string and get its value 7 45
MS SQL + date 6 51
Making Table Thru ASP Response.write 5 34
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

740 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