By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

Trouble with Strings

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a

"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

P: n/a
Thanks!
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.