doulezhi5326 2014-03-05 09:35
浏览 20
已采纳

Javascript曾经工作但现在却没有

This javascript worked before but just today, it doesn't. I tried adding alert() inside the functions.js but it doesn't pop up anymore. My javascript is enabled and pop up is enabled, too.

footer.php

<script type="text/javascript" src="<?php echo site_url('assets/js/jquery/jquery-1.11.0.min.js') ?>"></script>
<script type="text/javascript" src="<?php echo site_url('assets/js/jquery/functions.js') ?>"></script>
<script type="text/javascript" src="<?php echo site_url('assets/js/jquery/jquery.validate.js') ?>"></script>
<script type="text/javascript" src="<?php echo site_url('assets/js/jquery/additional-methods.js') ?>"></script>

functions.js

$("document").ready(function(){
alert("sfs");
$('#type').change(function () {
    if ($('#type').val() == 'fund') {
        $('#fund').show();
        $('#submit').show();
    } else if ($('#type').val() == 'attendance') {
        $('#fund').hide();
        $('#submit').show();
    } else {
        $('#fund').hide();
        $('#submit').hide();
    }
});
$("addmember").validate({
    rules: {
        id: {
            required: true,
            digits: true
        }
        lname: {
            required: true
        }
        fname: {
            required: true
        }
        mname: {
            required: true
        }
        contact: {
            digits: true
        }
        email: {
            email: true
        }

    }
});

});

tnew.php

<div id="content">
<center>
<h1>New Transaction</h1>
<?php echo form_open("home/transact"); ?>
<table>
    <tbody>
    <tr>
        <td>Name:</td>
        <td><input type="text" placeholder="Transaction" name="name" id="name" required/></td>
    </tr>
    <tr>
        <td>Type:</td>
        <td><?php 
                $options = array(
                    'select' => '(Select Type)',
                    'fund'  => 'Funds',
                    'attendance'    => 'Attendance'
                );
                $id = 'id = "type"';
                echo form_dropdown('type', $options, 'select', $id);
            ?>
        </td>
    </tr>
    <tr id="fund" style="display: none;">
        <td>Amount: </td>
        <td><input type="number" placeholder="Amount" name="amt" id="amt" /></td>
    </tr>
    <tr id="submit" style="display: none;">
        <td colspan = 2><?php echo form_submit("submit", "Add Transaction"); ?></td>
    </tr>
    </tbody>
</table>
</center>

Dropdown used to work but now, it doesn't. I'm also using codeigniter if that's an issue.

  • 写回答

3条回答 默认 最新

  • dtnbjjq51949 2014-03-05 09:40
    关注

    Looks like your rules are missing the comma (,) between your field configuration, it should be

    $("addmember").validate({
        rules: {
            id: {
                required: true,
                digits: true
            },
            lname: {
                required: true
            },
            fname: {
                required: true
            }
            mname: {
                required: true
            },
            contact: {
                digits: true
            },
            email: {
                email: true
            }
    
        }
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。