简体   繁体   中英

Include condition inside javascript in relation php constant

i would know how to include a condition inside js. Like you can see in my table I this constant MODE_B2B_B2C; How to make the same thing inside js.

Tk.

         <table width="100%" cellpadding="5" cellspacing="0" border="0">
           <tr>
        if (MODE_B2B_B2C == 'true') {
          $content .= '
                          <td>' . $this->app->getDef('table_heading_customers_group') . '</td>
                      ';
        }
</tr>
</table>

      $output = <<<EOD
<script type="text/javascript"><!--
  var quantitydiscount_row = $i;

  function addQuantityDiscountValue() {


   //customers_group_id
    html += '<td>';
    html += '  <select name="products_quantitydiscount[' + quantitydiscount_row + '][customers_group_id]" class="form-control">{$customers_group_name}</select>';
    html += '</td>';


    quantitydiscount_row++;
  }
</script>
<br />
EOD;

You can use Template Strings:

 let myVal = 123; function condition(input) { if (input > 10) return "foo"; return "bar"; } let str = `This will output ${myVal} * 2 = ${myVal * 2}. Condition: ${condition(2)} Condition: ${condition(20)} `; console.log(str); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM