Question

My if(str == seltext) is returning true, all the time.

heres my code:-

[% FOREACH cll = classifications %]
    var str = "[% cll.object.name FILTER js %]";
    var seltext = classSel.options[classInd].text;
    alert(str+" "+seltext);
    if(str == seltext)
    {
        alert("classfound=[% cll %]");     /// THIS ALWAYS GETS FIRED
    }
[% END %]

I cannot understand why this is happening, I think it might be because the [% only gets saved the the variable str once, but they my alert wouldn't change.

Was it helpful?

Solution

The way i fixed this was by revering the if statement so it goes like this

if(classSel.options[classInd].text == "[% cll.object.name FILTER js %]")

then it works

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top