如果我从dorpdown中选择本地销售并输入DEF,那么GHI值则DEF,GHI的总和应显示在总价值中,或者如果我从下拉列表中选择Inter State,Stock Transfers,那么如果我们输入ABC值,则该值应显示在总数中值或者如果我们从下拉列表中选择JOB WORK,EXEMPTED SALES,则总值应显示为零。 应该将我们获得的总值插入到数据库中。
控制器:
function addinvoice()
{
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters(' ','');
$this->form_validation->set_rules('user','User');
$this->form_validation->set_rules('freight_charges');
$this->form_validation->set_rules('abc');
$this->form_validation->set_rules('def');
$this->form_validation->set_rules('ghi');
$this->form_validation->set_rules('total');
if($this->form_validation->run()== FALSE)
{
$data['mainpage']='invoice';
$data['mode']='add';
$this->load->view('templates/template',$data);
}
else
{
$this -> invoice_model -> insert();
$this->flash->success('
Details added Successfully!
');redirect('invoice');
}
}
模型:
function insert()
{
$data['total']=0;
$data['user'] = $this->input->post('user');
$data['ghi'] = ($this->input->post('ghi'))?$this->input->post('ghi'):0;
$data['abc'] = ($this->input->post('abc'))?$this->input->post('abc'):0;
$data['def'] = ($this->input->post('def'))?$this->input->post('def'):0;
$data['total'] = $data['ghi'] + $data['abc'] + $data['def'];
$data['freight_charges'] = $this->input->post('freight_charges');
$this->db->insert('invoice',$data);
}
视图:
function showRequiredOption(cval)
{
if((cval=='interstate') || (cval == "stocktransfers"))
{
$('#ghi').hide();
$('#def').hide();
$('#abc').show();
}
else if ((cval=='exemptedsales') || (cval=="zeroratedsales") ||(cval=="jobwork"))
{
$('#ghi').hide();
$('#def').hide();
$('#abc').hide();
}
else
{
$('#abc').hide();
$('#ghi').show();
$('#def').show();
}
}
Profile Information
User
Local Sales
Inter state
Stock transfers
Exempted Sales
Zero Rated Sales
Job Work
Freight Charges
ABC
DEF
GHI
Total
Submit
无论我从下拉列表中选择什么值,只有那些要插入数据库的值,其余的值应该在数据库中插入零。
实际上我没有得到如何做这些可以任何人检查这个。谢谢你提前。