隐藏变量

时间:2014-04-15 23:16:33

标签: javascript php arrays variables

我有一个JavaScript待办事项列表,其中包含3个变量,这些变量是e数据库中表格中的3列,用于提取信息。 3是id,内容和状态,当在列表中显示数据时,它显示内容以及仅仅是数字的状态,数字决定了我使用CSS完成的内容的颜色,但是我没有&# 39; t想要在内容之后显示数字,有什么方法可以隐藏这个?

下面是一些提取它的PHP代码:

public function getList()
    {   
        $link = $this->connect();
        // Query for all the entries from the table and order them based on the id descendingly
        $query = "SELECT * FROM tbToDoList ORDER BY STATUS";

        $res = mysql_query($query);

        $res_array = array();
        // fetch all the entires one by one
        while($row=mysql_fetch_array($res)){
            // put query result in php array
            $array = array('id' => $row['id'],
                           'content' => $row['content'],
                           'status'=> $row['status']); 

这里有一些JS //渲染待办事项列表视图

todo.getView = function (res){
    // if the list has more than two entries, grants the permission to use massive weapon/delete all
    if(res.length >= 2){
        $('#massiveWeapon').css('display', 'block');
    }
    // update the list view
    for (var i=0; i< res.length; i++){
$("<li/>", {"id": res[i].id, "text": res[i].content + res[i].status, "class": 'status-' + res[i].status}).appendTo(todo.list);      if(res[i].content.length >= 35){
            $('#'+res[i].id).css("height","50px");
        }
    }
}       

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

在项目的javascript定义中,您将文本设置为res[i].content + res[i].status。如果您不想在文本中显示状态,请从文本中删除+ res[i].status

相关问题