用户
 找回密码
 入住 CI 中国社区
搜索
查看: 5167|回复: 10
收起左侧

小问题

[复制链接]
发表于 2008-8-20 10:46:29 | 显示全部楼层 |阅读模式
比如添加成功了 我想显示个添加成功的对话框 该怎么实现 谢谢
发表于 2008-8-20 10:52:26 | 显示全部楼层
alert('添加成功');
发表于 2008-8-20 10:55:01 | 显示全部楼层
转到另一个页面,添加那个方法
发表于 2008-8-20 11:41:38 | 显示全部楼层
//添加注册信息
function yzzhuce(){
      $this->db->insert('usertable',$_POST);
      //echo "信息添加成功";
    echo "<script text='javascript'>alert('注册成功');</script>";
    redirect('liuyan/liuyan/getzhuce');
}

[ 本帖最后由 degoogle 于 2008-8-20 11:42 编辑 ]
 楼主| 发表于 2008-8-20 13:19:01 | 显示全部楼层

不对啊

Cannot modify header information - headers already sent by (output started at E:\phpWeb\system\application\controllers\listclass.php:47)
不能修改头部信息啊
echo "<script text='javascript'>alert('注册成功');</script>";
redirect('listclass');
发表于 2008-8-20 17:23:06 | 显示全部楼层
输出头之前不能输出任何内容!
 楼主| 发表于 2008-8-21 14:40:04 | 显示全部楼层

HEX 那该怎么实现

HEX 那该怎么实现
发表于 2008-8-21 14:58:01 | 显示全部楼层
用 session 的  flash 内容,具体你可以用 CI 搜索引擎搜索一下。
这种内容放在  session 中,然后使用一次后就失效。
发表于 2008-8-21 15:06:45 | 显示全部楼层
3楼方法比较实在。
另外可以用ajax啊
发表于 2008-8-21 16:45:57 | 显示全部楼层
在show_error()所在的文件里自定义个
show_message()函数
function show_message($message, $url='', $t=3)
{
        require(APPPATH . 'views/message.html')        ;
        exit;
}

然后自己定制一个message.html文件来显示信息就可以了

<html>
<head>
<title>Error</title>
<meta http-equiv="Content-Type" c />
<style type="text/css">

body {
background-color:        #fff;
margin:                                40px;
font-family:                Lucida Grande, Verdana, Sans-serif;
font-size:                        12px;
color:                                #000;
}

#content  {
border:                                #999 1px solid;
background-color:        #fff;
padding:                        20px 20px 12px 20px;
text-align:center;
}

h1 {
font-weight:                normal;
font-size:                        14px;
color:                                #990000;
margin:                         0 0 4px 0;
}
</style>
<?php if($url): ?>
<meta http-equiv="refresh" c>
<?php endif; ?>
</head>
<body>
        <div id="content">
        <?php if($url): ?>
                <?=$message ?>
                <br />
                <a href="<?=$url?>">【<?=$t ?>秒钟后页面没有自动跳转,请手动点击点击返回】</a>
        <?php else: ?>
                <?php echo $message; ?>
                <br />
                <a href="javascript:window.history.go(-1);">【点击返回】</a><br />
        <?php endif; ?>
               
               
        </div>
</body>
</html>

本版积分规则