This is a snippet from something really simple I’m working on (unfortunately, I do not have much experience in Javascript). Basically, I need to print the values of multiple dynamic text fields in order (I’m assuming dynamic is the right word; more text boxes can be added or taken away depending on how many are needed). They are labeled like so:
<li><input type="text" name="feature_1" id="feature_1" /></li>
<li><input type="text" name="feature_2" id="feature_2" /></li>
etc
etc
I’ve been using this to try and get the input values from the text boxes.
amount = 4; //this is actually the total number of text boxes used
var count = 1;
while (count <= amount) {
var feature_text = "form.feature_" + count + ".value";
text += ("<li>" + feature_text + "</li>\n");
count++;
}
Unfortunately, this outputs
<li>form.feature_1.value</li>
<li>form.feature_2.value</li>
<li>form.feature_3.value</li>
<li>form.feature_4.value</li>
instead of
<li>Value 1</li>
<li>Value 2</li>
<li>Value 3</li>
<li>Value 4</li>
What do I do to get “feature_text” to pull the values instead of outputting a string?
Try this out