hi,
i have a site which contains one text box and a button. When the button is clicked it will search the database for whatever is in the text box.
i want to be able to just press enter rather than having to click the button, how is this done, can it not be done on a keypress event such as
on enter.down
do this
end ?
helpl please folks!!
steveI haven't tested this code so hopefully it works, otherwise it should only need a little tweeking. Add this Javascript function to the onkeypress event of your textbox.
function fnTrapKD(event){
var theForm = document.forms["TheIdValueOfYourForm"];
if (document.all){if (event.keyCode == 13){event.returnValue=false;event.cancel = true;theForm.submit();}}
else{if (event.which == 13){event.returnValue=false;event.cancelBubble = true;theForm.submit();}}
}
Like this:
onkeypress="fnTrapKD(event);"
i have a site which contains one text box and a button. When the button is clicked it will search the database for whatever is in the text box.
i want to be able to just press enter rather than having to click the button, how is this done, can it not be done on a keypress event such as
on enter.down
do this
end ?
helpl please folks!!
steveI haven't tested this code so hopefully it works, otherwise it should only need a little tweeking. Add this Javascript function to the onkeypress event of your textbox.
function fnTrapKD(event){
var theForm = document.forms["TheIdValueOfYourForm"];
if (document.all){if (event.keyCode == 13){event.returnValue=false;event.cancel = true;theForm.submit();}}
else{if (event.which == 13){event.returnValue=false;event.cancelBubble = true;theForm.submit();}}
}
Like this:
onkeypress="fnTrapKD(event);"