Javascript 如何使用脚本在cakephp中显示警报
嗨,我想知道如何用脚本在cakephp中显示警报…我有这个表单Javascript 如何使用脚本在cakephp中显示警报,javascript,php,cakephp-2.0,cakephp-2.3,Javascript,Php,Cakephp 2.0,Cakephp 2.3,嗨,我想知道如何用脚本在cakephp中显示警报…我有这个表单 <div class="soyaproductorcompras form"> <h3>Registro de Compra de Grano </h3> <?php echo $this->Form->create('SoyaProductorCompra');?> <fieldset> <?php ech
<div class="soyaproductorcompras form">
<h3>Registro de Compra de Grano </h3>
<?php echo $this->Form->create('SoyaProductorCompra');?>
<fieldset>
<?php
echo $this->Form->input('soya_proveedor_id', array( 'options' => $soyaproveedores,'empty' => '--Porfavor Seleccione Proveedor--','label' => 'Por Favor Seleccione a algun Proveedor de la lista' ));
echo $this->Form->input('producto', array(
'options' => array(
'GRANO DE SOYA' => 'Grano de Soya',
'GRANO DE GIRASOL' => 'Grano de Girasol'
), 'label'=>'Tipo de Grano '
));
echo $this->Form->input('toneladas', array('label' => 'Cantidad en tonelada(s) métrica(s) del producto (TM)','style'=>'width:500px; height:30px;','default'=>0));
echo $this->Form->input('preciodolar', array(
'label' => 'Precio en Dolares Americanos por tonelada métrica (TM / $us)',
'style'=>'width:500px; height:30px;',
'default'=>0));
echo $this->Form->input('total', array('label' => 'Total en Dolares Americanos ($us)','style'=>'width:500px; height:30px;','default'=>0));
echo $this->Form->input('fecharegistro', array('dateFormat' => 'DMY', 'minYear' => date('Y')-3,
'maxYear' => date('Y') + 1, 'label' => '<strong>Periodo al que corresponde la declaración jurada</strong>','empty'=>false, 'type'=>'date'));
echo $this->Form->submit('Agregar Existencia', array('class' => 'form-submit', 'title' => 'Presione aqui para agregar datos'));
?>
</fieldset>
<?php echo $this->Form->end(); ?>
</div>
格兰诺公司注册处
所以我不知道如何,在哪里放置脚本,以及如何调用它…此表单为DB发送数据…该部分工作正常!。。。但是我的客户希望看到一个带有这样一条信息的迷你屏幕:“你确定要保存此表单吗?”,他单击“是”或“否”,请帮助 我的问题在这里得到了很多帮助后得到了解决……所以我的代码有了一点变化……我只在Begining of my view添加了我的脚本
<script>
function show_alert()
{
if (confirm("¿Esta seguro guardar el formulario?")) { return true; }
return false;
}
</script>
请注意,该函数有此“返回”,并以“结束,如果你不把这些东西放进去,代码就不起作用了。。。我希望我的解决方案能有所帮助
Create js file and put it in webroot/js folder
just link it with your view as follows
echo $this->Html->script('your_file_name');
function desired_fun_name()
{
alert();
}
and write your desired function and call it on onclick
详情如下:
echo$this->Form->submit('Agregar Existencia',array('class'=>'Form submit','title'=>'Presione aqui para Agregar datos','onclick'=>'required_fun_name()) 因此,编写一些javascript截取表单提交并显示确认框。这不是CakePHP特有的,可以相对容易地完成。这里还有一个类似的问题——谢谢@cillosis,我看到了这个问题,我开始搜索html,而不是cakephp解决方案,现在我的代码可以工作了!。。我会把tje的解决方案给想要同样的人…再次感谢@塔索斯:谢谢,我看到了解决方案,帮了我很多!!!谢谢我很高兴成为starkoverflow家族的一员!!。。。谢谢
Create js file and put it in webroot/js folder
just link it with your view as follows
echo $this->Html->script('your_file_name');
function desired_fun_name()
{
alert();
}
and write your desired function and call it on onclick