Results 1 to 2 of 2

Thread: navigating controls with Enter

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    Not necessary, but it would be nice -

    I have a submission form AddDailyRept.asp that has 10 textbox controls on a form. The form is declared
    Code:
    <form action="DailyReportConfirmation.asp" method="post" id="frmSubmit">
    The information is submitted to DailyReportConfirmation.asp and then processed. I would like for the user to be able to navigate the fields with the Enter key and only submit the information when they press Enter when the last field has the focus. As of right now, the Enter key submits the form no matter which control has the focus. I have this code for each text box:
    Code:
    <SCRIPT LANGUAGE="VBScript">
    <!-- hide language from older browsers that don't recognize the SCRIPT tag
    Public TheForm
    
    On Error Resume Next
    
    Sub cmbFacility_OnKeyPress
    
    	Dim KeyPressed
    
    	Set TheForm = Document.forms("frmSubmit")	
    	KeyPressed=Window.Event.KeyCode
    
    	If KeyPressed = 13 Then 'sends focus to next control.  
    		TheForm.TheDate.Focus()
    	End If
    
    End Sub
    but that gets overridden. Is there any way to do this?

  2. #2
    Lively Member harsoni's Avatar
    Join Date
    Oct 2000
    Posts
    118

    Lightbulb

    well one way to go about is

    <INPUT TYPE=button VALUE="Submit" onclick="yourfunction()" id=button1 name=button1>

    onsubmit call a function yourfunction() and in this function check if the focus was in the last input...if so submit..else don't...this way u can avoid the use of cmbFacility_OnKeyPress in all the inputs...


    Sonia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width