【发布时间】:2015-11-04 13:09:25
【问题描述】:
我有一个用于添加、查看更新和删除的表单。
我的页面包含带有编辑和删除链接的表格。
当我点击编辑链接时,它会在文本框中显示选定的行数据。
如何填充选定的行数据并在文本框中显示?
这一切都在codeIgnitter中。
plz see the attached screen shots here for refrence of my view 代码如下:
控制器
public function edit()
{
$id = $this->input->get('id');
$this->db->where('id',$id);
$data['query'] = $this->db->get('categort_tbl');
$data['id'] = $id;
$this->load->view('category', $data);
}
public function select()
{
$data['title'] = "Welcome to DB";
$data['results'] = $this->category_model->getAll();
$this->load->view('category',$data);
}
表单和列表视图 category.php
<form name="frm1" method="post" action="<?php echo base_url(); ?>category/save">
<table height="40px">
<tr>
<td width="9%">Category :</td>
<td width="21%"><input type="text" name="category" required="" size="40" value=""/></td>
<td width="48%"><input type="submit" class="submit_button" name="save" value="Save"/></td>
</tr>
</table>
</form>
</div>
<div id="page-wrap">
<table width="60%" border="1">
<tr>
<td>Category</td>
<td>Date</td>
<td colspan="2" style="text-align:center">Actions</td>
</tr>
<?php if(isset($results)){ foreach($results as $row) { ?>
<tr>
<td><?php echo $row->category; ?></td>
<td><?php echo $row->created; ?></td>
<td><?php echo anchor('category/edit?id='.$row->id,'Edit')?></td>
<td><?php echo anchor('category/delete?del='.$row->id,'Delete',array('onclick' => "return confirm('Do you want delete this record')"))?></td>
</tr>
<?php } } ?>
</table>
</div>
【问题讨论】:
-
所以你希望类别文本框有来自点击行的数据?这听起来像javascript工作。从表格行中获取值并将它们添加为文本框的内部 html
标签: php codeigniter