现在我试图从另一种形式获取价值。但我不知道如何制作它。
这是我的第一个表格:
这是方法,当我们在form1中单击“提交”时,页面将重定向到此方法。
public function input_data_inserted()
{
$id_data_inserted = $this->input->post('id_data_inserted');
$date = $this->input->post('date');
$id_data = $this->input->post('id_data');
$amount= $this->input->post('amount');
$id_room = $this->input->post('id_room');
$passed = FALSE;
$checkIdData = $this->modelku->cek_idData()->result_array();
$checkIdRoom = $this->modelku->cek_idRoom()->result_array();
foreach ($cekIdData as $cID)
{
foreach ($cekIdRoom as $cIR)
{
if ($id_data == $cID['id_data'] && $id_room == $cIR['id_room'])
{
$data = array
(
'id_data_inserted' => $id_data_inserted,
'date' => $date,
'id_data' => $cID['id_data'],
'amount' => $amount,
'id_room' => $cIR['id_room'],
);
$this->modelku->input_data($data, 'table_data_inserted');
$data['table_data_inserted'] = $this->modelku->show_data('table_data_inserted')->result();
$this->modelku->increase_value($amount, $id_data);
//redirect to second form
redirect('admin/Data/data\view_detail_data');
$passed = TRUE;
break;
}
}
}
if(!$passed)
{
echo "ERORR";
}
}
这是我的第二种形式:
第二种形式的方法:
public function input_detail_barang()
{
$id_data = $this->input->post('id_data');
$no_inv = $this->input->post('no_inv');
$condition = $this->input->post('condition');
$data = array
(
'id_data' => $id_data,
'no_inv' => $no_inv,
'condition' => $condition
);
//I need amount from first form, because i will use it. How can i do?
}
任何解决方案? THX
答案 0 :(得分:0)
在此行之后,您可以将其保存到会话:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr class='group'> <td>Group 1 </td> </tr>
<tr> <td> Group 1 item 1</td> </tr>
<tr> <td> Group 1 item 2</td> </tr>
<tr> <td> Group 1 item 3</td> </tr>
<tr class='group'> <td> group 2</td> </tr>
<tr> <td> group 2 item 1</td> </tr>
<tr class='group'> <td> group 3</td> </tr>
<tr class='group'> <td> group 4</td> </tr>
<tr class='group'> <td> group 5</td> </tr>
<tr> <td> group 5 item 1</td> </tr>
<tr> <td> group 5 item 2</td> </tr>
</table>
为了显示这个数据添加这一行:
$data = array (
'id_data_inserted' => $id_data_inserted,
'date' => $date,
'id_data' => $cID['id_data'],
'amount' => $amount,
'id_room' => $cIR['id_room'], // You missed single quote here
);
$this->load->library('session');
$this->session->set_userdata("Firstformdata",$data);