Kiyomori
07-29-2003, 09:47 AM
I have a very interesting situation. Using Javascript, I want to populate the inner HTML values of Option tags.
The OPTION tags look like this:
(OPTION ID="Top_0" VALUE="0000")(/OPTION)
(OPTION ID="Top_1" VALUE="0001")(/OPTION)
The problem I'm having is, I can't create a loop that will fill them sequentually.
This is the best I have:
(All the extra variables have been declared globally)
("Top" and "Bottom" refer to 2 combo boxes that will do the exact same thing)
function FillOptionValues()
// Action: Fills the archive ComboBoxes with comic titles
// Call: LoadLastComic()
// Note: This is a temporary solution to autowriting the option html in Javascript
{
// Declare local variables
var varCount = 0;
var varTopDocWriter = "document.Top_" + varCount + ".document.write";
var varTopInnerHTML = "Top_" + varCount + ".innerHTML";
var varBottomDocWriter = "";
var varBottomInnerHTML = "";
var varDocComicTitle = varComicTitleArray[varCount];
// Begin Procedure
while (varCount < conLastComicNumber + 1)
{
if (!document.write)
{
varTopDocWriter = varDocComicTitle;
}
else
{
varTopInnerHTML = varDocComicTitle;
}
++varCount;
}
return;
}
The obvious problem to this is is, I can't get the script to do the actions stored in varTopDocWriter and varTopInnerHTML. In fact, I'm embarrasssed to say it took me a few moments to realise all I was doing was writing over what's already in those variables.
Can anyone think of a solution to this problem or an alrenative besides filling the values in manually?
The OPTION tags look like this:
(OPTION ID="Top_0" VALUE="0000")(/OPTION)
(OPTION ID="Top_1" VALUE="0001")(/OPTION)
The problem I'm having is, I can't create a loop that will fill them sequentually.
This is the best I have:
(All the extra variables have been declared globally)
("Top" and "Bottom" refer to 2 combo boxes that will do the exact same thing)
function FillOptionValues()
// Action: Fills the archive ComboBoxes with comic titles
// Call: LoadLastComic()
// Note: This is a temporary solution to autowriting the option html in Javascript
{
// Declare local variables
var varCount = 0;
var varTopDocWriter = "document.Top_" + varCount + ".document.write";
var varTopInnerHTML = "Top_" + varCount + ".innerHTML";
var varBottomDocWriter = "";
var varBottomInnerHTML = "";
var varDocComicTitle = varComicTitleArray[varCount];
// Begin Procedure
while (varCount < conLastComicNumber + 1)
{
if (!document.write)
{
varTopDocWriter = varDocComicTitle;
}
else
{
varTopInnerHTML = varDocComicTitle;
}
++varCount;
}
return;
}
The obvious problem to this is is, I can't get the script to do the actions stored in varTopDocWriter and varTopInnerHTML. In fact, I'm embarrasssed to say it took me a few moments to realise all I was doing was writing over what's already in those variables.
Can anyone think of a solution to this problem or an alrenative besides filling the values in manually?