如果是的话..是如何完成的?我知道这可能是一个愚蠢的问题,但我不确定它是如何完成的。下面这个脚本:
<script type="text/javascript">
$(document).ready(function(){
$('charge_amt').keyup(function(){
var that = this;
$('#charge_cc').prop('checked', function(){
return that.value.length;
});
});
});
</script>
我如何将它集成到这个类中:
class OkToShipEDPump extends \Komment
{
/**
Declare any autofill data.
*/
protected function my_data()
{
}
/**
Declare all fields applicable to this comment, with any display options.
*/
protected function my_fields()
{
$help = new FieldHelp($this->patient);
return array(
input_group('Call Type'
,input_select('call_type'
, array('NC'=>'OK - NO CHANGES'
,'IN'=>'OK - PENDING INS'
,'PI'=>'OK - PENDING INS/PO'
,'PO'=>'OK - PENDING PO'
), 'NC', 1)->label(' ')->reason_swap()
)->left()
,input_group('Copay and Credit Card',
input_text('copay', 20)
,input_check('charge_cc')
,input_text('cc_amt', 20)->label()->mand()
)->right()
,input_group('Please fill in info'
,input_hidden('category', 'OK')
,input_text('spoke_to', 30, 'PT')->mand()
,input_date('ship_date', date("n/j/Y"))->reason_show('call_type', 'nc')
)->left()
,input_group('ED Supply'
,input_select('ed_pump',ptdme('L7900'), '', 1)->label('ED Pump ')->mand()
)->right()
,input_group('Additional Notes',
input_tbox('additional_notes', 3, 80, 250)->label()
)->whole()
);
}
我把它放在类(class)末尾的 php 结束标记之后,但它不起作用。我想这是因为它必须在实际字段之前调用。
任何和所有的帮助将不胜感激。谢谢。
最佳答案
您本身无法在您的类中“执行”javascript,但您可以通过简单地回显它来将其包含在您的页面中...
<?php
...
echo <<<JS
<script type="text/javascript">
$(document).ready(function(){
$('charge_amt').keyup(function(){
var that = this;
$('#charge_cc').prop('checked', function(){
return that.value.length;
});
});
});
</script>
JS;
...
?>
关于php - 是否可以在 php 类中包含 <script type ="text/javascript"> ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16968219/