php表单value值为数据库里的值还可以修改后再导入数据库么,php - 在输入表单中的值并使用codeigniter插入数据库后获取总值 - 堆栈内存溢出...

如果我从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

无论我从下拉列表中选择什么值,只有那些要插入数据库的值,其余的值应该在数据库中插入零。

实际上我没有得到如何做这些可以任何人检查这个。谢谢你提前。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值