p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: how to override enter


Message #1 by bharath reddy <bharath_reddy@u...> on 12 Sep 00 00:38:45 MDT
Hi,
  My problem is... 

          is there a methos to find out which element or field in the for
m is
generating the event when we submit the form.for eg. i have ten fields wh
ich
are 10 text fields to enter the answers to the questions.i want to know w
hich
field i am in when the enter is pressed and send to the event handler so 
that
i can send the control or focus to the next field.Now i am capturing the 
event
and if enter is pressed it stays in the same field.
=2E
=2E
=2E..    

<%the event handler%>
function checkEnter(evt){
var theKey
if (isNav){
        theKey =3D evt.which
        }
        else{
        theKey =3D window.event.keyCode
        }
        if (theKey=3D=3D13){
           return false;
        }
}

return false if the key pressed is enter from the function.
so if the enter is pressed it stays in the same field
=2E
=2E.
 <form method=3D"post" action=3D"quiz.asp"  name=3D"foQuiz" onkeypress   
  =3D "return
checkEnter(event);">
=2E
=2E
<input type=3D"text" name=3D"userans<%=3Di%>" >
=2E
=2E

i tried to put the  [onkeypress=3D "return checkEnter(event);"] in the te
xt
fields but no use.

i know it is script problem but if some body would have faced this proble
m
please help me.

bharath.e










  Return to Index