douwei9973 2014-12-15 13:18
浏览 105

未捕获的TypeError:undefined不是一个函数(匿名函数)php javascript

I am not very familiar with javascript and I am also pretty new here. I am getting an error on the console that says Uncaught TypeError: undefined is not a function.

I am trying to sort a table and create a pagination in php. There's no fatal error but it won't work. I don't know why. Here's my code:

header.php

<!-- Mobile viewport optimisation -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- Add meta data here -->

<link id="bootstrapFlexible" href="styles/flexible-columns.css" rel="stylesheet" type="text/css"/>

<link id="bootstraptheme" rel="stylesheet" type="text/css" href="css/bootstrap.css">



<link rel="stylesheet" type="text/css" href="css/jquery.css" />

<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/jquery.tablesorter.js" type="text/javascript"></script> 
<script type="text/javascript"> 
    $(document).ready(function() { 
        $("table").tablesorter({ 
            sortList: [[2,0]],
            // pass the headers argument and assing a object 
            headers: { 
                // assign the secound column (we start counting zero) 
                5: { 
                    // disable it by setting the property sorter to false 
                    sorter: false 
                }           
            } 
        }); 
    });
</script>

<meta charset="utf-8"/>

    <script>
        function settheme() {
            if (localStorage.getItem("settheme") === null) {

            }else{
                var theme = localStorage['settheme'];
                document.getElementById('bootstraptheme').href = theme;
            }
        };
         window.onload = settheme;

    </script>

This is my table:

$query = $dbh -> query("SELECT COUNT(*) FROM reminders r 
        JOIN reminder_type rt 
        ON r.type_of_reminder = rt.reminder_type_id
        JOIN subjects s
        ON r.subject = s.subject_id");

$num_rows=$query->rowCount();
$rows = $query->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT);
$pages = new Paginator;
$pages->items_total = $rows[0];
$pages->mid_range = 5; // Number of pages to display. Must be odd and > 3
$pages->paginate();
echo $pages->display_pages();
echo "<span class=\"\">".$pages->display_jump_menu().$pages->display_items_per_page()."</span>";

echo "<form method='POST'>
    <input type='text' name='search_key'/>
    <input type='submit' name='search_button' value='S E A R C H'/>
    </form>";

echo '<table style="width:100%;margin:auto; text-align: center;" id="bord" class="tablesorter">';
echo '<thead id="table_head">
<tr style="height:50px;font-size:18px;font-weight:bold; background:#00a651; color:#fff;"">';
echo "  <th class='thh'>Name</th>
        <th class='thh'>Subject</th>
        <th class='thh'>Reminder Type</th>
        <th class='thh'>Description</th>
        <th class='thh'>Date of Deadline</th>
        <th class='thh'>Time of Deadline</th>
        <th>Option</th>
        </tr></thead>
        <tbody>";

And this is the paginator class that I got from the web.

I appreciate all your suggestions guys. I already looked up on SO but I can't seem to find the solution. So, thank you, guys!

  • 写回答

1条回答 默认 最新

  • duanmei9980 2014-12-15 13:22
    关注

    On the script part you put }; to close the function settheme().

    <script>
        function settheme() {
            if (localStorage.getItem("settheme") === null) {
    
            }else{
                var theme = localStorage['settheme'];
                document.getElementById('bootstraptheme').href = theme;
            }
        };
    

    Try to remove the extra ;

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器