Holly
Holly

Reputation: 3

Quotes in JQuery / JavaScript when using PHP print function

I'm trying to debug someone's code and have hit a bit of a rookie error.

Now while this works on Xserve (or at least it kindly ignores it), when running on a linux server it refuses to co-operate and knocks out a function lower down.

I'm pretty sure what I need to do here is address the quotes: the scope of the quotes seems to be wrong - the first double quote links to the third and the second to the fourth. Any ideas very very welcome!

<?php foreach ($years as $id => $title) : ?>
$("#<?php print $id ?>_both").click(function() {
$(".<?php print $id ?>.g, .<?php print $id ?>.b")
.attr("checked", $("#<?php print $id ?>_both").attr("checked"));
});
<?php endforeach; 

Upvotes: 0

Views: 482

Answers (1)

Blazes
Blazes

Reputation: 4779

The quotes look okay (awful, but okay). Are you sure you aren't missing an end php (last line):

<?php foreach ($years as $id => $title) : ?>
$("#<?php print $id ?>_both").click(function() {
$(".<?php print $id ?>.g, .<?php print $id ?>.b")
.attr("checked", $("#<?php print $id ?>_both").attr("checked"));
});
<?php endforeach; ?>

Upvotes: 1

Related Questions