dav_asp
04-13-2007, 11:11 AM
Hi,
i've got an asp page that displays a lot of records from a DB. I added some javascript to get the user to input a number that should be displayed on the page. It's meant to work like the find option in microsoft programs.
Everytime the button submitting the number is pressed, a warning message is displayed in the bottom-left corner of the browser that says "Error on page".
here's my coding:
var numtimes = 0;
function findinpage(str) {
if (str == "") return false;
if (document.layers) {
if (!window.find(str)) {
while(window.find(str, false, true)) n++;
}
else numtimes++;
if (numtimes == 0) alert("The invoice number \""+ str +"\" was not found on this page.");
}
if (document.all) {
var txt = window.document.body.createTextRange();
var found = txt.findText(str);
for (var i = 0; i <= numtimes && found != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
numtimes++;
}
else {
if (numtimes > 0) {
numtimes = 0;
findinpage(str);
}
else alert("The invoice number \""+ str +"\" was not found on this page.");
}
return false;
}
}
i've got an asp page that displays a lot of records from a DB. I added some javascript to get the user to input a number that should be displayed on the page. It's meant to work like the find option in microsoft programs.
Everytime the button submitting the number is pressed, a warning message is displayed in the bottom-left corner of the browser that says "Error on page".
here's my coding:
var numtimes = 0;
function findinpage(str) {
if (str == "") return false;
if (document.layers) {
if (!window.find(str)) {
while(window.find(str, false, true)) n++;
}
else numtimes++;
if (numtimes == 0) alert("The invoice number \""+ str +"\" was not found on this page.");
}
if (document.all) {
var txt = window.document.body.createTextRange();
var found = txt.findText(str);
for (var i = 0; i <= numtimes && found != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
numtimes++;
}
else {
if (numtimes > 0) {
numtimes = 0;
findinpage(str);
}
else alert("The invoice number \""+ str +"\" was not found on this page.");
}
return false;
}
}