I have a problem with using a function within a loop, the function contains a switch-statement and it breaks up the code (literally) because the switch-statement contains breaks.
function presentation(input, fixedid)
{
switch(fixedid)
{
case 1:
output = namesplice(input);
break;
case 6:
output = str_remain(input, '0123456789');
break;
case 8:
output = str_replace(' ', '', strtoupper(input));
break;
case 11:
output = str_remain(input, '0123456789');
break;
default:
output = input;
break;
}
return output;
}
for (i=1;i<=cellCount;i++)
{
label = $('#cell0_'+ i).html();
for (j=1;j<=count(targetcolumns);j++)
{
if (jQuery.inArray(strtolower(label), sub[targetcolumns[j] + '_label']) >= 0)
{
result = $('#content'+ i).html();
result = presentation(result, j);
$('#result'+ j).append(result);
}
}
}
It goes wrong on this piece of code: result = presentation(result, j);
What the rest of the code does isn't really important, the only thing you should know that it is within two loops. The function gets called and then breaks out of the first loop, starting it over again and thus creating a unending loop.
How can I use the function without breaking up the rest of my code?
count,strtolowerand all the other functions actually defined? Looks a bit like a mixture of PHP and JavaScript.