bing19880122 发表于 2008-8-20 10:46:29

小问题

比如添加成功了 我想显示个添加成功的对话框 该怎么实现 谢谢

degoogle 发表于 2008-8-20 10:52:26

alert('添加成功');

degoogle 发表于 2008-8-20 10:55:01

转到另一个页面,添加那个方法

degoogle 发表于 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 编辑 ]

bing19880122 发表于 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');

Hex 发表于 2008-8-20 17:23:06

输出头之前不能输出任何内容!

bing19880122 发表于 2008-8-21 14:40:04

HEX 那该怎么实现

HEX 那该怎么实现

Hex 发表于 2008-8-21 14:58:01

用 session 的flash 内容,具体你可以用 CI 搜索引擎搜索一下。
这种内容放在session 中,然后使用一次后就失效。

kissmumu 发表于 2008-8-21 15:06:45

3楼方法比较实在。
另外可以用ajax啊

shangwu 发表于 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>
页: [1] 2
查看完整版本: 小问题