dynamic coding.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Bedford

    dynamic coding.

    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.bo dy.createTextRa nge();
    var oRng2 = oRng1.duplicate ();
    var oRng3 = oRng1.duplicate ();
    ....
    oRng1.moveToEle mentText(win.DI VBrother);
    oRng2.moveToEle mentText(win.DI VCanon);
    oRng3.moveToEle mentText(win.DI VEpson);
    ....
    if(win.DIVBroth er.style.visibi lity=='visible' ) var bInside =
    oRng1.inRange(T Range);
    if(win.DIVCanon .style.visibili ty=='visible') var bInside =
    oRng2.inRange(T Range);
    if(win.DIVEpson .style.visibili ty=='visible') var bInside =
    oRng3.inRange(T Range);
    ....
    if(win.DIVBroth er.style.visibi lity=='visible' ) {
    TRange.moveToEl ementText(win.D IVBrother);
    strFound=TRange .findText(str);
    TRange.select() ;
    }
    if(win.DIVCanon .style.visibili ty=='visible') {
    TRange.moveToEl ementText(win.D IVCanon);
    strFound=TRange .findText(str);
    TRange.select() ;
    }
    if(win.DIVEpson .style.visibili ty=='visible') {
    TRange.moveToEl ementText(win.D IVEpson);
    strFound=TRange .findText(str);
    TRange.select() ;
    }
    ....
    TRange=win.docu ment.body.creat eTextRange();
    if(win.DIVBroth er.style.visibi lity=='visible' )
    TRange.moveToEl ementText(win.D IVBrother);
    if(win.DIVCanon .style.visibili ty=='visible')
    TRange.moveToEl ementText(win.D IVCanon);
    if(win.DIVEpson .style.visibili ty=='visible')
    TRange.moveToEl ementText(win.D IVEpson);

    if(oRng1.inRang e(TRange)) {win.tab0.focus (); win.tab0.click( );}
    if(oRng2.inRang e(TRange)) {win.tab1.focus (); win.tab1.click( );}
    if(oRng3.inRang e(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


  • ExGuardianReader

    #2
    Re: dynamic coding.

    Bob Bedford wrote:
    [color=blue]
    > 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).
    >[/color]

    You need to use a J2EE webserver (Tomcat is free) and custom tags. It's
    fairly simple to write a <mytags:tabse t> tag which will contain
    <mytags:tab>s .

    Comment

    Working...