How to compress string on PHP? For instance I have PHP function called form_dropdown()
which return into:
<select name="selecOP" id="selecOP">
<option value=" ">Select selecOP</option>
<option value="1">test1</option>
<option value="2">test2</option>
<option value="2">test2</option>
</select>
Then I call the php function to JavaScript:
$("#addrow").on("click", function () {
counter = $('#myTable tr').length - 2;
var newRow = $("<tr>");
var cols = "";
cols += '<td><?php echo form_dropdown("selecOP' + counter + '"); ?></td>';
cols += '<td><textarea name="price' + counter + '" rows="1px" cols="50px"></textarea></td>';
cols += '<td><button class="ibtnDel btn btn-xs btn-danger"></i> Delete</button></td>';
cols += ' </td>';
newRow.append(cols);
if (counter == 4) $('#addrow').attr('disabled', true).prop('value', "You've reached the limit");
$("table.order-list").append(newRow);
counter++;
});
My problem is the browsers returns an error Uncaught SyntaxError: Unexpected token ILLEGAL
. I tried it manually with straight format and it works but with block format it give me an error.
Expected output:
<select name="selecOP' + counter + '" id="selecOP"><option value="1">test1</option><option value="2">test2</option></select>