What I need to do, is to set the property name dynamically. I will show you the code I am trying:
for (i = 0; i < $nrOfCriteriiReducere; i++)
{
var eroareText = "eroareIDCazReducere" + " " + i;
var eroareHtmlClass = ".eroareCazReducere" + i;
if (raspuns.eroriProprietar.eroareText)
{
$(eroareHtmlClass).css("display", "inline");
$(eroareHtmlClass).text(raspuns.eroriProprietar.eroareText);
}
}
It is not working, and it is giving me the:
Uncaught SyntaxError: Unexpected string error.
How can I achieve this?
Solution:
Here is the solution (I also changed it by setting the name attribute dynamically, and not the class):
for (i = 0; i < $nrOfCriteriiReducere; i++)
{
var eroareText = "eroareIDCazReducere" + " " + i;
var eroareName = "eroareCazReducere" + i;
if (raspuns.eroriProprietar[eroareText])
{
var name = "[name=" + eroareName + "]";
$(name).css("display", "inline");
$(name).text(raspuns.eroriProprietar[eroareText]);
}
}