Hello,
I've coded a tab pages somes years ago, with a search engine (with the help
of an other programmer) allowing to search in many divs (any tab show/hide a
div).
Now, I've to change code as new tabs are added. I've a frame where I load
the tabs and fill div with queries, and an other frame where I have the
search form. I'm looking for a way to have dynamic creation of the code,
depending on the loaded divs or tabs.
Here is the javascript code allowing to switch DIV for finding any string in
many DIVS, then show the desired DIV.
....
var oRng1 = win.document.body.createTextRange();
var oRng2 = oRng1.duplicate();
var oRng3 = oRng1.duplicate();
....
oRng1.moveToElementText(win.DIVBrother);
oRng2.moveToElementText(win.DIVCanon);
oRng3.moveToElementText(win.DIVEpson);
....
if(win.DIVBrother.style.visibility=='visible') var bInside =
oRng1.inRange(TRange);
if(win.DIVCanon.style.visibility=='visible') var bInside =
oRng2.inRange(TRange);
if(win.DIVEpson.style.visibility=='visible') var bInside =
oRng3.inRange(TRange);
....
if(win.DIVBrother.style.visibility=='visible') {
TRange.moveToElementText(win.DIVBrother);
strFound=TRange.findText(str);
TRange.select();
}
if(win.DIVCanon.style.visibility=='visible') {
TRange.moveToElementText(win.DIVCanon);
strFound=TRange.findText(str);
TRange.select();
}
if(win.DIVEpson.style.visibility=='visible') {
TRange.moveToElementText(win.DIVEpson);
strFound=TRange.findText(str);
TRange.select();
}
....
TRange=win.document.body.createTextRange();
if(win.DIVBrother.style.visibility=='visible')
TRange.moveToElementText(win.DIVBrother);
if(win.DIVCanon.style.visibility=='visible')
TRange.moveToElementText(win.DIVCanon);
if(win.DIVEpson.style.visibility=='visible')
TRange.moveToElementText(win.DIVEpson);
if(oRng1.inRange(TRange)) {win.tab0.focus(); win.tab0.click();}
if(oRng2.inRange(TRange)) {win.tab1.focus(); win.tab1.click();}
if(oRng3.inRange(TRange)) {win.tab2.focus(); win.tab2.click();}
For now I've 9 tabs, but the customer want to add 3 more, and maybe once
will want to add some new. I'd like to be able to manage this kind of code
dynamically, but don't know how to do.
Anybody may help me change the code above to do it dynamically managing that
the tabs and DIVs come from an access database ? maybe with an array or
whatever.
Thanks.
Bob