<?php echo $this->Html->css('../js/plugins/datepicker/datepicker', array('inline' => false)); echo $this->Html->script('plugins/datepicker/bootstrap-datepicker', array('inline' => false)); echo $this->Html->css('../js/plugins/fileupload/bootstrap-fileupload', array('inline' => false)); echo $this->Html->script('plugins/fileupload/bootstrap-fileupload', false); echo $this->Html->script('holder', false); $this->extend('/Layouts/portlet'); $this->assign('contentHeader', $contentHeader); $this->start('portletHeader'); echo $this->Icon->get('add'); echo $this->Label->get('student.add'); $this->end(); $this->start('portletBody'); $formOptions = $this->FormUtility->getFormOptions(array('action' => 'add')); echo $this->Form->create('Sale',$formOptions); echo '<div class="form-group">'; echo $this->Form->input('date',array('label' => array('class' => 'col-md-2 control-label'))); echo '</div>'; echo '<div class="form-group">'; echo $this->Form->input('name',array('type'=>'select','options'=>$names,'label' => array('class' => 'col-md-2 control-label'))); echo '</div>'; echo '<div class="form-group">'; echo $this->Form->input('product',array('type'=>'select','options'=>$na,'id'=>'prd','label' => array('class' => 'col-md-2 control-label'))); echo '</div>'; echo '<div class="form-group">'; echo $this->Form->input('qty',array('id'=>'qt','label' => array('class' => 'col-md-2 control-label'))); echo '</div>'; echo '<div class="form-group">'; echo $this->Form->input('amount',array('id'=>'amt','label' => array('class' => 'col-md-2 control-label'))); echo '</div>'; echo $this->Form->end(__('Submit')); ?> </div> <div class="actions"> <h3><?php echo __('Actions'); ?></h3> <ul> <li><?php echo $this->Html->link(__('List Sales'), array('action' => 'index')); ?></li> <?php App::import('Controller', 'SalesController'); $EmpCont = new SalesController; $EmpCont->tests(); ?> </ul> </div> <script type="text/javascript"> $(document).ready(function(){ $('#qt').change(function () { var data= $('#prd').val(); $.ajax({ url: '/tests', type: 'POST', data: {data,data}, success: function (data) { //add the content retrieved from ajax into whatever forms you like // $("#otherbox").val(data.[User][information][here]); // $("#otherbox").val(data.[User][information][here]); // $("#otherbox").val(data.[User][information][here]); // $("#otherbox").val(data.[User][information][here]); alert(data); } , error : function() { alert("cannot send data"); } }); }); }); </script> <?php $this->end(); ?>