如何在html字段中从php调用javascript函数 您需要将这些js函数包装在标记中,比如您的js代码在这里您编写'、'chbx(this);'、'在输入字段中?你不能那样做onclick=“chbx(this);对于输入标记已经足够了。写下你的if

如何在html字段中从php调用javascript函数 您需要将这些js函数包装在标记中,比如您的js代码在这里您编写'、'chbx(this);'、'在输入字段中?你不能那样做onclick=“chbx(this);对于输入标记已经足够了。写下你的if,php,jquery,function,checkbox,jscript,Php,Jquery,Function,Checkbox,Jscript,如何在html字段中从php调用javascript函数 您需要将这些js函数包装在标记中,比如您的js代码在这里您编写'、'chbx(this);'、'在输入字段中?你不能那样做onclick=“chbx(this);对于输入标记已经足够了。写下你的if-else条件是否打印onclick。这就足够了。在页面末尾,在脚本标记中,你必须定义你的函数。比如:函数chbx(var){//在这里写你的代码},因为如果$paypal=,我需要调用函数是”和checkbox=“checked”onclic

如何在html字段中从php调用javascript函数
您需要将这些js函数包装在
标记中,比如
您的js代码在这里
您编写
'、'chbx(this);'、'在输入字段中?你不能那样做
onclick=“chbx(this);
对于输入标记已经足够了。写下你的if-else条件是否打印
onclick
。这就足够了。在页面末尾,在脚本标记中,你必须定义你的函数。比如:
函数chbx(var){//在这里写你的代码}
,因为如果$paypal=,我需要调用函数是”和checkbox=“checked”onclick用于当用户单击复选框时,php$根据另一个页面的post变量设置复选框。另外,代码中有标记,b4和之后,我只是没有在重写示例中添加它们
<div>

 <input  type="checkbox" id="paypal" name="paypal"  value=" "  <?php if ($paypal="yes"): ?> checked="checked"  <?php echo '<script type="text/javascript">','chbx(this);','</script>'; ?> <?php endif; ?>  onclick="chbx(this);" ></input>

    <label for="paypal" id='paypal2' class="checkboxes" >Show PayPal Accepted <?php echo $paypal; ?></label>
<br>

<input   type="checkbox" id="facebook"  name="facebook"  value=" "  <?php if ($facebook="yes"):  ?>  checked="checked"  <?php endif; ?>   onclick='chbx(this);' >
</input>
<label for="facebook" id='facebook2' class="checkboxes"  >Show FaceBook Contact Details</label>

<br>

<input   type="checkbox" id="twitter"  name="twitter"  value=" "    <?php if ($twitter="yes"):  ?> checked="checked" <?php endif; ?>   onclick='chbx(this);' >
</input>
<label for="twitter" id='twitter2' class="checkboxes"  >Show Twitter Contact Details</label>
</div>



<div id='paypal1'  class='listfooterinfo' ><span style='color:blue;'>PayPal Accepted:</span>An Icon Will Let Your Buyers Know You Accept PayPal For Payments</div>
<div id='facebook1' class='listfooterinfo'><span style='color:blue;'>Facebook Contact:</span> An Icon Will Allow Buyers To Contact You Via Facebook</div>
<div id='twitter1'  class='listfooterinfo'><span style='color:blue;'>Twitter Contact:</span>An Icon Will Allow Buyers To Contact You Via Twitter</div>



<script>        
    function chbx(obj) {


       var that = obj;

    if(document.getElementById(that.id).checked === true) 

        {
        document.getElementById(that.id).checked = true;
        document.getElementById(that.id).value='yes';
        document.getElementById(that.id+"1").classList.add("listfooterinfoin");



        } 

    else 

        {
        document.getElementById(that.id).checked === false 
        document.getElementById(that.id).checked = false;
        document.getElementById(that.id).value='no';
        document.getElementById(that.id+"1").classList.remove("listfooterinfoin");

        }

    }

</script>
"
<?php if ($paypal="yes"): ?> checked="checked"  <?php echo '<script type="text/javascript">','chbx(this);','</script>'; ?> <?php endif; ?> 
"
 $("input[type=checkbox]").change(function() {  
     if($(this).is(":checked")) {
        chbx(this);
        chbxB(this);
        chbxF(this);
     }
      else {
        // remove the items 
     }
    });