Solved

ASP Focus problem

Posted on 2016-11-08
3
29 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
  • 2
3 Comments
 
LVL 32

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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/…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

18 Experts available now in Live!

Get 1:1 Help Now