470,613 Members | 2,427 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,613 developers. It's quick & easy.

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 Verse1NewAmericanStandard = new String( "Your will be done. (NASB)" );
var Verse2KingJames = new String( "Thou shalt not... (KJV)" );
var Verse2NewAmericanStandard = new String( "You are not to... (NASB)" );

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

//Assuming the user selected NASB, theSelectedTranslation will contain the
value "0."
theSelectedTranslation = document.getElementById( whichBibleVerse
).selectedIndex;

//theTranslationAbbreviation will contain the value "NewAmericanStandard."
if ( theSelectedTranslation == 0 )
{
theTranslationAbbreviation = new String( "KingJames" );
}
if ( theSelectedTranslation == 1 )
{
theTranslationAbbreviation = new String( "NewAmericanStandard" );
}

//theStringToDisplay will contain the value "Verse1NewAmericanStandard."
theStringToDisplay = new String( theBibleVerse + theTranslationAbbreviation );

//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 "Verse1NewAmericanStandard" rather than "Your will be done.
(NASB)." How do I correct this?
document.getElementById( theBibleVerse ).innerHTML = theStringToDisplay;
}

<!-- 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, HandleVersionChange() 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 = "bibleTranslation" id = "BibleVerse1" onchange =
"HandleVersionChange( 'Verse1' );">
<option selected="selected">KJV</option>
<option>NASB</option>
</select>
</td>
<td>
<div id = "Verse1">Thy will be done. (KJV)</div>
</td>
<td>Genesis ?:?</td>
</tr>
</table>

<table>
<tr>
<td>
<select class = "bibleTranslation" id = "BibleVerse2" onchange =
"HandleVersionChange( 'Verse2' );">
<option selected="selected">KJV</option>
<option>NASB</option>
</select>
</td>
<td>
<div id = "Verse2">Thou shalt not... (KJV)</div>
</td>
<td>Matthew ?:?</td>
</tr>
</table>
Thanks,
Jim
Jul 20 '05 #1
2 1242

"BrassWorld" <br********@aol.com> schreef in bericht
news:20***************************@mb-m28.aol.com...

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)" );
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.
//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 "Verse1NewAmericanStandard" rather than "Your will be done. (NASB)." How do I correct this?
document.getElementById( theBibleVerse ).innerHTML = theStringToDisplay;
}


document.getElementById(theBibleVerse).innerHTML =
window[theStringToDisplay];
JW

Jul 20 '05 #2
Thanks!
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

39 posts views Thread by Erlend Fuglum | last post: by
4 posts views Thread by Guilherme Salgado | last post: by
6 posts views Thread by DJ | last post: by
3 posts views Thread by Aaron Walker | last post: by
11 posts views Thread by KraftDiner | last post: by
1 post views Thread by yucikala | last post: by
8 posts views Thread by merrittr | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.