[英]PHP echo with Javascript error
'.(($disablez > 0)?'<script type="text/javascript"> $(".lcs_check"").lcs_on(); </script>':"").'
Hello, I am using this code inside an echo. 您好,我在回显内使用此代码。 but the problem is it doesnt work!.
但问题是它不起作用! the main point is its a switch that turns ON/OFF and I use PHP codes to get the value but now I want it to be on if it found the disablez more than 0,
要点是它的开关可以打开/关闭,我使用PHP代码获取该值,但是现在我希望它在发现disablez大于0时将其打开,
I tried putting $(".lcs_check"").lcs_on();
in a <style>
outside the echo and it works fine. 我试着将
$(".lcs_check"").lcs_on();
放在回显之外的<style>
,并且效果很好。
Full Echo 全回声
echo' <form action="" method="post">
<div class="control-group">
<label for="title" class="pull-left label label-info span2">News Name</label>
<div class="control">
<input type="text" id="title" name="title" value="'.$row["title"].'"" />
</div>
</div> <br /><br /><br />
<div>
<label for="content" style="padding-top: 7px;"class="pull-left label label-info span2">Description</label><br /><br />
<div class="control">
<textarea class="ckeditor" name="content" id="content" cols="30" rows="10"> '.$row["content"].' </textarea>
</div>
</div> <br />
<div class="control-group">
<p><input type="checkbox" name="check-1" id="check-1"value="1" class="lcs_check" autocomplete="off" /></p>
'.(($disablez > 0)?'<script type="text/javascript"> $(".lcs_check"").lcs_on(); </script>':"").'
</div>
<div class="control-group">
<div class="control">
<input id="addProjectAdd" type="submit" class="btn btn-sharp btn-success" value="Update News" />
</div>
</div>
</form>';
}
You had two double quotes in there.
您在那里有两个双引号。
$(".lcs_check").lcs_on(); $(“。lcs_check”)。lcs_on();
echo '...</p> ' . ($disablez > 0) ? '<script> $(".lcs_check").lcs_on(); </script>':'' . ' </div> ...';
If your code is correct, this should do the trick 如果您的代码正确,这应该可以解决问题
Update.. Full Code.. 更新..完整代码..
echo' <form action="" method="post">
<div class="control-group">
<label for="title" class="pull-left label label-info span2">News Name</label>
<div class="control">
<input type="text" id="title" name="title" value="'.$row["title"].'" />
</div>
</div> <br /><br /><br />
<div>
<label for="content" style="padding-top: 7px;"class="pull-left label label-info span2">Description</label><br /><br />
<div class="control">
<textarea class="ckeditor" name="content" id="content" cols="30" rows="10"> '.$row["content"].' </textarea>
</div>
</div> <br />
<div class="control-group">
<p><input type="checkbox" name="check-1" id="check-1"value="1" class="lcs_check" autocomplete="off" /></p>
' . ($disablez > 0) ? '<script> $(".lcs_check").lcs_on(); </script>':'' . '
</div>
<div class="control-group">
<div class="control">
<input id="addProjectAdd" type="submit" class="btn btn-sharp btn-success" value="Update News" />
</div>
</div>
</form>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.