Enter key to submit fom

Hi everybody,

I’ve a problem with this java script code which allows to submit a form pressing enter key.

The form (opened in Notes) returns Java Script Error. Sometimes also after minutes and minutes of good work.

Apparently no specific reason seems to invoke the error!

Current code:

ON JS HEADER:

var newline = String.fromCharCode(10);

var useClick;

var sString;

var t_sString;

function runSearch() {

sString = document.forms[0].CodProdottoFinito.value;

if (sString.indexOf(newline)>=0) {

	t_sString = replace(sString, '\n', '');

	document.forms[0].CodProdottoFinito.value = t_sString;

	document.forms[0].PrintButton.click();

}

}

function replace(str, from, to) {

var i = str.indexOf(from);

if (!from || !str || i == -1)

	return str;

var newstr = str.substring(0, i) + to;

if (i+from.length < str.length)

	newstr += replace(str.substring(i+from.length,str.length),from,to);

return newstr;

}


ON_BLUR of CodProdottoFinito:

window.clearInterval(useClick);


ON_FOCUS of CodProdottoFinito:

useClick = window.setInterval(“runSearch()”,5);


Could anyone help me?

Thanks!

Subject: Enter key to submit fom

What is the error?And you are saying you open it from notes might it be a better idea to write in then in formula/lotusscript?

Subject: Enter key to submit fom

Problem solved…

There were redundant lines of code:

ONLOAD of form

useClick = window.setInterval(“runSearch()”,5);

ON_FOCUS of CodProdottoFinito:

useClick = window.setInterval(“runSearch()”,5);

Only one needed.