简体   繁体   English

在与php常量相关的javascript中包含条件

[英]Include condition inside javascript in relation php constant

i would know how to include a condition inside js. 我会知道如何在js中包含条件。 Like you can see in my table I this constant MODE_B2B_B2C; 就像您在我的表格中看到的那样,此常量MODE_B2B_B2C; How to make the same thing inside js. 如何在js中做同样的事情。

Tk. k

         <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); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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