function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sapsap 

Problem with page refresh

Hi,

I have a command button which is used to submit a form with some search text.

I want to submit the form even when the user presses 'Enter Key', so used java script to implement this.

Im using the following code

function handleKeyPress(e){
var sbutton = document.getElementById("{!$Component.form1.block.pbs.pbsi.btn}");

var key= 0;
if(window.event){
key= e.keyCode;
}else if(e.which){
key= e.which;
}
if(key==13){
sbutton.click();
}
}





I'm displaying the fetched data in a pageblocktable.



when I click enter the javascript function is called and the data table is getting refreshed with the fetched results.

But with in a moment the page is again getting refreshed/redirected back to the previous set of results.

I'm not sure what I'm I missing.

Any pointers will be of great help.

Thanks
Swapna