0
我有這個javascript檢查付款是否等於或大於總數,
window.print同樣執行重定向頁面,但它只打印
但不重定向。JavaScript不會執行(codeigniter)在window.print()後的PHP腳本
視圖頁面:
<script>
function printpage()
{
var
total = parseFloat($(':input[name="total"]').val(),10),
cash = parseFloat($(':input[name="cash"]').val(),10),
charge = parseFloat($(':input[name="charge"]').val(),10),
payment = (cash + charge);
if(payment>= total){
window.print();
}else{
return false;
}
}
</script>
im not good at javascript.
here is some more details:
<form action="bills/settle" method="post">
<input type="text" name="cash">
<input type="text" name="charge">
<input type="text" name="total" value="<?php echo $total">
<input type="submit" onclick="printpage()"
</form>
控制器頁:
function settle(){
$payment = $this->input->post('cash')+ $this->input->post('charge');
$total = $this->input->post('total');
$data = ('cash'=>$this->input->post('cash'), so on.....)
if($payment >=$total)
{
$this->load->model('process');
$this->process->close_bill($data);
} else {
redirect('msg','refresh');
}
}
*其他注意事項,
如果付款OK: 它打印,插入數據的數據庫,但不重定向。
重定向腳本在我的模型中插入成功的db後。
如果付款不正常:(這邊沒問題)
它重定向到味精頁,
對不起,我已經離開了一個星期的互聯網,謝謝你的迴應。 – swordfish