I'm having a problem with the following bit of code and I'm wondering what I'm doing wrong.
I'm getting an Uncaught SyntaxError: Unexpected token ) error on the line where the eval call is made.
function myfunction(){
var p1 = '';
var p2 = '';
var p3 = '';
for (i=1; i<=3; i++){
eval("$('#p"+i+"').closest('.filter').find('.vals div').each(function(){if ($.trim(p"+i+").length > 0) {p"+i+" += ',';} p"+i+" += $(this).attr('class');});");
}
}
Here is the applicable HTML:
<div class="filter">
<label>Organizations</label>
<input id="p1" type="text" value="" />
<div class="vals">
<div class="3" title="Click to remove">ABC School District</div>
<div class="4" title="Click to remove">DEF School District</div>
</div>
</div>
<div class="filter">
<label>Groups</label>
<input id="p2" type="text" value="" />
<div id="vals"></div>
</div>
If it isn't completely obvious I'm also using jQuery here.
Thanks
eval()in the first place ... You have a hard to debug statement. I don't see why you can't write this withouteval()...