Skip to main content
Inspiring
November 5, 2015
Question

Javascript - Wildcards and Loops

  • November 5, 2015
  • 0 replies
  • 185 views

Hi

I'm a javascript newbie.

I have a slide with multiple text entry boxes and one Submit button.

When submit is clicked i execute a function - the code is in the Index file.

What i want to do now is create loops within the function to condense the code (i also want to reuse the Function on different slides).

I wrote the code out in long form - check if each text box has text, when they all have text - check to see if text is correct or not.

Now i want to see if i can condense the code using Loops.

I have two questions:

Question 1:

It it possible to use wildcards to append numbers and slide numbers to captivate variables and objects:

i.e when you use "window.(variable)" or "get" and "set" variables (getElementById, getVariableValue) ?

So can "v_teb01_slide01" be "v_teb(number)_(slidenumber)"?

Question 2:

How would i create the loops - what would the "endvalue" be?

for (i = 0; i < endvalue??; i++) {

    if ( window.v_teb01 == "" ) ,,,,,,,,,,

}

Regards

Donal.

    This topic has been closed for replies.