-3

I' want to show this input via php echo but when i remove the readonly property from an input in the following php sentence:

    <?
echo '<input class="form-control" name="cant-'.$indice.'+'.($t+1).'" id="cant-'.$indice.'+'.($t+1).'" value="'.$cant_guardada.'" readonly="true" ondblclick="this.readOnly='';" onblur="this.readOnly='true';">';
 ?>

And it's throwing this: Error: syntax error, unexpected '';" onblur="this.readOnly='' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';'

I know it's a quote related error but I can't seem to find it, can someone help me!

Chrishow
  • 363
  • 1
  • 5
  • 13
  • At the very least show us the piece of code that throws the error, not the piece of code that works. – deceze Sep 07 '17 at 16:01
  • Between PHP Echo statements with double inverted commas never use double inverted commas... Never.(Especially if you are going to write frontend code with attributes) – Rishabh Kandari Sep 07 '17 at 16:04
  • Edit! Sorry, copied the error from the same line with onblur added. – Chrishow Sep 07 '17 at 16:05

1 Answers1

1
<?php echo '<input class="form-control" name="cant-'.$indice.'+'.($t+1).'" id="cant-'.$indice.'+'.($t+1).'" value="'.$cant_guardada.'" readonly="true" ondblclick="this.readOnly=\'\';">';  ?>

The single quotes at this.readOnly='' need to be escaped

Manav
  • 1,357
  • 10
  • 17