Hi im adding a label and a text field to a table every time the button is clicked but im also trying to give each label an incremented value but I keep getting an Unexpected identifier error. The code is as follows:
var counter = 2;
$('.addButton').click(function()
{
$('#existingRow').after($('<tr><td><?php $cou = 2; echo $this->Form->label('Option' + $cou + ':'); $cou++ ?></td><td><?php echo $this->Form->input('name', array('label' => '', 'style' => 'height: 10px; width: 150px;')); ?></td></tr>'));
counter++;
});
Any help is greatly appreciated.
you can’t use JS variable counter inside PHP code block. Try:
If it works, instead of labelname you can then insert here whatever is generated with
and then change 2 with counter in JS