What will the jQuery syntax for new line inside php?

Viewed 50

I am trying to find the operator in jQuery to write code in next line when jq code inside php

Here is my working code:-

        <?php
    $addoldgoldrow = '    
                                    $(document).on("click",".add_btns",function(e) {             
                                        e.preventDefault();
                                        var markups = "<tr class=\'rowaccs\'><td><input type=\'text\' class=\'sl_no\' name=\'sl_no[]\' style=\'width: 100%\'></td><td><input type=\'text\' class=\'oweight inputbox input_table1\' name=\'oweight[]\' style=\'width: 100%\'></td><td><input type=\'text\' class=\'ostone_weight  inputbox input_table1\' name=\'ostone_weight[]\' style=\'width: 100%\'></td><td><input type=\'text\' class=\'ovd inputbox input_table1\' name=\'ovd[]\' style=\'width: 100%\'></td><td><input type=\'text\' class=\'onet_weight inputbox input_table1\' name=\'onet_weight[]\'  style=\'width: 100%\'></td><td><input type=\'text\' class=\'orate inputbox input_table1\' name=\'orate[]\' value=\'' . $metal_rate . '\' style=\'width: 100%\'></td><td><input type=\'text\' class=\'oamount inputbox input_table1 table1_end row_end\' name=\'oamount[]\'  style=\'width: 100%\' readonly></td><td><span class=\'rowcloseoldgold\'><i class=\'fa fa-times\' style=\'color: #C11429;\' aria-hidden=\'true\'></i></span></td</tr>";
                                        $("table#old_gold tbody").append(markups);
                                        indexassigneroldpurchase(); 
                                    });       
                ';
    $this->registerJs($addoldgoldrow, View::POS_READY);
    ?>

AND I AM TRYING TO DO LIKE THIS

     <?php
    $addoldgoldrow = '    
                                    $(document).on("click",".add_btns",function(e) {             
                                        e.preventDefault();
                                        var markups = "<tr class=\'rowaccs\'>
                                                        <td><input type=\'text\' class=\'sl_no\' name=\'sl_no[]\' style=\'width: 100%\'></td>
                                                        <td><input type=\'text\' class=\'oweight inputbox input_table1\' name=\'oweight[]\' style=\'width: 100%\'></td>
                                                        <td><input type=\'text\' class=\'ostone_weight  inputbox input_table1\' name=\'ostone_weight[]\' style=\'width: 100%\'></td>
                                                        <td><input type=\'text\' class=\'ovd inputbox input_table1\' name=\'ovd[]\' style=\'width: 100%\'></td>
                                                        <td><input type=\'text\' class=\'onet_weight inputbox input_table1\' name=\'onet_weight[]\'  style=\'width: 100%\'></td>
                                                        <td><input type=\'text\' class=\'orate inputbox input_table1\' name=\'orate[]\' value=\'' . $metal_rate . '\' style=\'width: 100%\'></td>
                                                        <td><input type=\'text\' class=\'oamount inputbox input_table1 table1_end row_end\' name=\'oamount[]\'  style=\'width: 100%\' readonly></td>
                                                        td><span class=\'rowcloseoldgold\'><i class=\'fa fa-times\' style=\'color: #C11429;\' aria-hidden=\'true\'></i></span></td</tr>";
                                        $("table#old_gold tbody").append(markups);
                                        indexassigneroldpurchase(); 
                                    });       
                ';
    $this->registerJs($addoldgoldrow, View::POS_READY);
    ?>

the + operator didn't works

I tried "+" and '+'
What operator is ideally used to connect these lines?

1 Answers

Simply add \ in the end of each line

So your code looks like this:

$addoldgoldrow = '    
  $(document).on("click",".add_btns",function(e) {             
    e.preventDefault();
    var markups = "<tr class=\'rowaccs\'> \
                    <td><input type=\'text\' class=\'sl_no\' name=\'sl_no[]\' style=\'width: 100%\'></td> \
                    <td><input type=\'text\' class=\'oweight inputbox input_table1\' name=\'oweight[]\' style=\'width: 100%\'></td> \
                    <td><input type=\'text\' class=\'ostone_weight  inputbox input_table1\' name=\'ostone_weight[]\' style=\'width: 100%\'></td> \
                    <td><input type=\'text\' class=\'ovd inputbox input_table1\' name=\'ovd[]\' style=\'width: 100%\'></td> \
                    <td><input type=\'text\' class=\'onet_weight inputbox input_table1\' name=\'onet_weight[]\'  style=\'width: 100%\'></td> \
                    <td><input type=\'text\' class=\'orate inputbox input_table1\' name=\'orate[]\' value=\'' . $metal_rate . '\' style=\'width: 100%\'></td> \
                    <td><input type=\'text\' class=\'oamount inputbox input_table1 table1_end row_end\' name=\'oamount[]\'  style=\'width: 100%\' readonly></td> \
                    td><span class=\'rowcloseoldgold\'><i class=\'fa fa-times\' style=\'color: #C11429;\' aria-hidden=\'true\'></i></span></td</tr>";
    $("table#old_gold tbody").append(markups);
    indexassigneroldpurchase();
});  ';     
Related