这是我的视图文件(registration_view.php)
<?php echo form_open("user/registration"); ?>
<p>
<label for="first_name">First Name:</label>
<input type="text" id="first_name" name="first_name" value="<?php echo set_value('first_name'); ?>" />
</p>
<p>
<label for="last_name">Last Name:</label>
<input type="text" id="last_name" name="last_name" value="<?php echo set_value('last_name'); ?>" />
</p>
<p>
<label for="email">Email Address:</label>
<input type="text" id="email" name="email" value="<?php echo set_value('email'); ?>" />
<p>
<label for="pickup_address">Pick up Address:</label>
<input type="text" id="pickup_address" name="pickup_address" value="<?php echo set_value('pickup_address'); ?>" />
</p>
<p>
<label for="postal_code1">Postal code:</label>
<input type="text" id="postal_code1" name="postal_code1" value="<?php echo set_value('postal_code1'); ?>" />
</p>
<p>
<input type="submit" class="greenButton" value="Submit" />
</p>
<?php echo form_close(); ?>
My controller user.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User extends CI_Controller{
function __construct() {
parent::__construct();
$this->load->model('user_model');
}
public function index()
{
$this->load->view('registration_view');
}
public function registration()
{
$this->user_model->add_registration();
}
}
模型(user_model.php)
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
class User_model extends CI_Model {
function __construct()
{
parent::__construct();
}
public function add_registration()
{
$data=array(
'first_name'=>$this->input->post('first_name'),
'last_name'=>$this->input->post('last_name'),
'email'=>($this->input->post('email'),
'pickup_address'=>$this->input->post('pickup_address'),
'postal_code1'=>$this->input->post('postal_code1'),
);
$this->db->insert('user',$data);
}
}
这是我的应用。这是工作。我需要这个视图分离为两个视图。名字、姓氏和电子邮件属于one_view.php,其他属于另一个视图(second_view.php)。单击one_view.php文件中的下一个按钮,然后打开second_view.php,而不转到数据库的值。然后,如果单击second_view.php中的提交按钮,所有值将传递给用户表…请帮助我如何通过使用ajax或jquery分离视图文件
可以显示两个视图
方法如下
从控制器显示第一个视图
$this->load->view("one_view",$data);
现在从你的one_view.php使用。你可以播第二种视图。
// from inside one_view.php
<div id="g" style="display:none">
<?php
$this->load->view("second_view",$pass_data);
?>
</div>
你从一个控制器加载两个视图。现在要显示第二个视图,您可以使用jquery来显示第二个视图。
然后提交你的表单或者其他东西