Solved

ASP Focus problem

Posted on 2016-11-08
3
60 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 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

786 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