?
Solved

ASP Focus problem

Posted on 2016-11-08
3
Medium Priority
?
96 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 34

Accepted Solution

by:
Big Monty earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

850 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