我用的CI框架
//前台页面
//AJAX传值函数
<script language="javascript">
function
addlist()
{
var
list=document.getElementById('id').value;
var
name=document.getElementById('name').value;
xajax_addlist(list,name); //CI框架方法
}
</script>
//CI框架标头
<?php echo
$xajax_js?>
//保存ID和名称的隐藏域
<input type="hidden"
id="id" />
<input type="hidden"
id="name" />
//商品添加按钮代码
<a onmouseover="javascript:document.getElementById('id').value='<?php echo $keyw->Id;?>',document.getElementById('name').value='<?php echo $keyw->name; ?>'" style="cursor:pointer" onclick="javascript:addlist()"><img src="<?php echo $base_url?>img/add.gif" border="0" /></a>
//后台代码
//CI框架写法
$this->load->library('xajax');
$this->xajax->decodeUTF8InputOn();
$this->xajax->registerFunction(array('addlist',$this,'addlist'));
$this->xajax->processRequests();
ADDLIST 页面
$obj_list=new xajaxResponse();
if($this->session->userdata("list")=="")
//取用户添加公司的列表
{
$aa='<input type="checkbox" name="list[]"
value="'.$id.'" />'.$name.'<br
/>';
//创建列表
$this->session->set_userdata("list",$aa);
//放到SESSION
}else
{
$bb=$this->session->userdata("list");
//取列表
$cc=preg_match("/".$id."/",$bb);
//对比是否添加过
if(!$cc)
//前台页面
//AJAX传值函数
<script language="javascript">
</script>
<?php echo
//保存ID和名称的隐藏域
<input type="hidden"
<input type="hidden"
//商品添加按钮代码
<a onmouseover="javascript:document.getElementById('id').value='<?php echo $keyw->Id;?>',document.getElementById('name').value='<?php echo $keyw->name; ?>'" style="cursor:pointer" onclick="javascript:addlist()"><img src="<?php echo $base_url?>img/add.gif" border="0" /></a>
//后台代码
//CI框架写法
$this->load->library('xajax');
ADDLIST 页面
$obj_list=new xajaxResponse();