Trouble with Strings

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

    #1

    Trouble with Strings

    Hello!

    I have two tables. Each displays a make believe Bible verse in the King James
    Version. Using a select list (there is one for each verse) the user can choose
    to display either verse in the New American Standard version instead. The
    comments between the <!-- --> (just above the tables) explain the specific
    problem I'm having. Any help is appreciated.

    var Verse1KingJames = new String( "Thy will be done. (KJV)" );
    var Verse1NewAmeric anStandard = new String( "Your will be done. (NASB)" );
    var Verse2KingJames = new String( "Thou shalt not... (KJV)" );
    var Verse2NewAmeric anStandard = new String( "You are not to... (NASB)" );

    function HandleVersionCh ange( theBibleVerse )
    {
    //If the user made a change in the first verse's select list, whichBibleVerse
    will contain the value "BibleVerse 1."
    whichBibleVerse = new String( "Bible" + theBibleVerse );

    //Assuming the user selected NASB, theSelectedTran slation will contain the
    value "0."
    theSelectedTran slation = document.getEle mentById( whichBibleVerse
    ).selectedIndex ;

    //theTranslationA bbreviation will contain the value "NewAmericanSta ndard."
    if ( theSelectedTran slation == 0 )
    {
    theTranslationA bbreviation = new String( "KingJames" );
    }
    if ( theSelectedTran slation == 1 )
    {
    theTranslationA bbreviation = new String( "NewAmericanSta ndard" );
    }

    //theStringToDisp lay will contain the value "Verse1NewAmeri canStandard."
    theStringToDisp lay = new String( theBibleVerse + theTranslationA bbreviation );

    //At this point, the first verse should change to display the New American
    Standard version of the verse rather than the King James Version. Instead, the
    text displayed is "Verse1NewAmeri canStandard" rather than "Your will be done.
    (NASB)." How do I correct this?
    document.getEle mentById( theBibleVerse ).innerHTML = theStringToDisp lay;
    }

    <!-- These are the HTML tables (I'm only showing the bare necessities.). The
    original text displays properly. When the user selects the NASB option from the
    select list, HandleVersionCh ange() is called. It determines which verse needs
    to be re-displayed and with what translation. The last line in that function
    (the one that actually displays the change) is the one giving me trouble. -->
    <table>
    <tr>
    <td>
    <select class = "bibleTranslati on" id = "BibleVerse 1" onchange =
    "HandleVersionC hange( 'Verse1' );">
    <option selected="selec ted">KJV</option>
    <option>NASB</option>
    </select>
    </td>
    <td>
    <div id = "Verse1">Th y will be done. (KJV)</div>
    </td>
    <td>Genesis ?:?</td>
    </tr>
    </table>

    <table>
    <tr>
    <td>
    <select class = "bibleTranslati on" id = "BibleVerse 2" onchange =
    "HandleVersionC hange( 'Verse2' );">
    <option selected="selec ted">KJV</option>
    <option>NASB</option>
    </select>
    </td>
    <td>
    <div id = "Verse2">Th ou shalt not... (KJV)</div>
    </td>
    <td>Matthew ?:?</td>
    </tr>
    </table>


    Thanks,
    Jim
  • Janwillem Borleffs

    #2
    Re: Trouble with Strings


    "BrassWorld " <brassworld@aol .com> schreef in bericht
    news:2003120703 0421.14191.0000 0415@mb-m28.aol.com...[color=blue]
    >
    > I have two tables. Each displays a make believe Bible verse in the King[/color]
    James[color=blue]
    > Version. Using a select list (there is one for each verse) the user can[/color]
    choose[color=blue]
    > to display either verse in the New American Standard version instead. The
    > comments between the <!-- --> (just above the tables) explain the specific
    > problem I'm having. Any help is appreciated.
    >
    > var Verse1KingJames = new String( "Thy will be done. (KJV)" );[/color]

    You don' t have to use the String object to create a new string, a simple:

    var Verse1KingJames = "Thy will be done. (KJV)";

    will do.
    [color=blue]
    > //At this point, the first verse should change to display the New American
    > Standard version of the verse rather than the King James Version. Instead,[/color]
    the[color=blue]
    > text displayed is "Verse1NewAmeri canStandard" rather than "Your will be[/color]
    done.[color=blue]
    > (NASB)." How do I correct this?
    > document.getEle mentById( theBibleVerse ).innerHTML = theStringToDisp lay;
    > }
    >[/color]

    document.getEle mentById(theBib leVerse).innerH TML =
    window[theStringToDisp lay];


    JW



    Comment

    • BrassWorld

      #3
      Re: Trouble with Strings

      Thanks!

      Comment

      Working...