douxi3432 2014-12-26 09:53
浏览 280
已采纳

JS简单的函数调用不起作用

im new to codeginiter and its developing. i used dropbox (html select box) when i pressed option there. i need to trigger a alert box.in oder to do that i used following code. But it didnt work on me. and i could find the mistake i've done please help me.

<html lang="en">
    <head>
        <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
        <meta content="utf-8" http-equiv="encoding">

        <title>Ask Questions</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">


        <link href="<?php echo base_url(); ?>css/bootstrap.min.css" rel="stylesheet">
        <link href="<?php echo base_url(); ?>css/style.css" rel="stylesheet"> 

<script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.min.js">

                   // untill select catogory tags are disabled


                   function activate_match()
                   {
                      // var tnmt_id = "hip hure";
                       alert("tested");
                       //Get the id of the tournament selected in the list
                   }


</script>


    </head>

<body>
        <div class="container">
            <p class="help-block">
                How to Ask </br>
                Is your question about DIY ? </br>
                We prefer questions that can be answered, not just discussed.<br>
                Provide details. Share your experience. </br>

            </p>


            <div class="form-group">

                <?php
                echo form_open('homepage/askquestionview');
                echo validation_errors();
                ?>  
            </div>

            <p> </p>



            <div class="form-group">


                <select name="cat" id="cat" onchange="activate_match()">
<?php
                   foreach($catogories as $cat) {
                    echo'<option value="' . $cat . '">' . $cat . '</option>';
                }
                ?>

                </select>




            </div>

            <div class="form-group">
                <p>
                    Description: <br/>

                    <textarea name="decription" rows="5" cols="100"> </textarea>
                </p>
            </div>



            <p></p>                

            <div class="form-group">
                Declare new Tags:<br/>

                <input type="text" value="" name="tag">
                </p>
            </div>

        </div>                             <p>
            <input type="submit"  class="btn btn-success btn-block" value="Post Your Question" id="postQuestion">
        </p>
        <?php echo form_close(); ?>


    </body>


</html>
  • 写回答

3条回答 默认 最新

  • du12197 2014-12-26 10:00
    关注

    You need to have two separate script tags:

    <script src="<?php echo base_url(); ?>js/jquery.min.js"></script>
    <script>
       function activate_match() {
           // var tnmt_id = "hip hure";
           alert("tested");
           //Get the id of the tournament selected in the list
       }
    </script>
    

    If script has src attribute its inner content is ignored. So the first script is to load jQuery, and the second to declare you functions.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题