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 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误