Code:
for(int j=0; j<virtualFields.length();j++)
{
finalOptions += '<option value="'+virtualFields[j]+'"><\/option>' ;
}
Firebug is giving this error:
Missing ; after for loop initializer.
Javascript doesn't understand int. Use var instead.
Some other pointers:
virtualFields is an ordinary array, length is a property, not a method.virtualFields[j] values that you're concatenating like that./ inside a regular expression, not within an ordinary string. So </option> would work just fine.(these points are not related to the error, but you may wish to take them into account anyway)
/: some HTML parsers think that every closing tag, i.e., everything that starts with </, is the closing tag of the script element. That's also why it is advised to either escape those tags appearing within strings in JavaScript, or split the string like this: "<"+"/end>".<script> tag, I'm well aware that breaks. It's because once you open the tag, the HTML parser looks only for a closing </script> tag, ignoring everything else. It finds that "inside the JS string", but the parser won't care about whether it's in a string or not (it doesn't understand Javascript). The same thing does not happen with other closing tags, hence why I questioned Marcel's assertion that it happened for every closing tag.