残疾人无法工作

时间:2016-08-26 16:48:15

标签: javascript jquery html

我在下面的HTML文档中。

<%@page import="org.bean.UserBean"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript"
    src="http://code.jquery.com/jquery-1.10.0.min.js"></script>

<link rel="stylesheet" type="text/css" href="CSSFiles/myCssFile.css">
<script type="text/javascript">
    function dynamicdropdown(listindex) {
        document.getElementById("subtask").length = 0;
        switch (listindex) {
        case "break":
            document.getElementById("subtask").options[0] = new Option(
                    "Please select Break type");
            break;
        case "ORD Meetings":
            document.getElementById("subtask").options[0] = new Option(
                    "Please select type of Meeting", "");
            break;
        case "Training":
            document.getElementById("subtask").options[0] = new Option(
                    "Please select Type of Training", "");
            break;
        case "project":
            document.getElementById("subtask").options[0] = new Option(
                    "Please select type of Project", "");
            break;

        }
        return true;
    }
</script>

<script type="text/javascript">
    $(document).ready(function() {
        if (typeof (Storage) !== "undefined") {
            var stat = localStorage.getItem("clickStat");
            if (stat == "start") {
                $('#Start').attr("disabled", true);
                $('#Stop').attr("disabled", false);

            } else {
                $('#Start').attr("disabled", false);
                $('#Stop').attr("disabled", true);
            }
        }
        var form = $('#formSec');
        var task = document.getElementById('task');
        var subtask = $('#subtask');

        $('#Start').on("click", function() {
            if (typeof (Storage) !== "undefined") {
                localStorage.setItem("clickStat", "start");
            }
            $.ajax({
                type : "post",
                url : "UpdateStartTime",
                data : form.serialize(),
                success : function() {
                    $('#task').attr("disabled", true);
                    $('#subtask').attr("disabled", true);
                    $('#Start').attr("disabled", true);
                    $('#Stop').attr("disabled", false);
                    $('#getCase').attr("disabled", true);
                }
            });
            return false;
        });

        $('#Stop').on("click", function() {
            if (typeof (Storage) !== "undefined") {
                localStorage.setItem("clickStat", "stop");
            }
            var form = $('#formSec');
            var task = document.getElementById('task');
            var subtask = $('#subtask');
            $.ajax({
                type : "post",
                url : "UpdateEndTime",
                data : form.serialize(),
                success : function() {
                    $('#task').attr("disabled", false);
                    $('#subtask').attr("disabled", false);
                    $('#Start').attr("disabled", false);
                    $('#Stop').attr("disabled", true);
                    $('#getCase').attr("disabled", false);
                }
            });
            return false;
        });

    });
</script>

</head>
<body>
    <div class="header" id="header">
        <form id="form1"></form>
    </div>
    <form name="formSec" id="formSec">
        <div class="bodytag1">
            <table>
                <tr>
                    <td colspan="2" align="center"><span
                        class="font-style-boldItalic">Breaks</span></td>
                </tr>
                <tr>
                    <td>Break Task</td>
                    <td><select id="task" name="task"
                        onchange="javascript: dynamicdropdown(this.options[this.selectedIndex].value);">
                            <option value="" disabled selected>Select</option>
                            <option value="break" id="break">Break</option>
                            <option value="ORD Meetings" id="ORD Meetings">ORT
                                Meetings</option>
                            <option value="Training" id="Training">Training</option>
                            <option value="project" id="project">Adhoc Project</option>
                    </select></td>
                </tr>
                <tr>
                    <td>SubTask</td>
                    <td><select id="subtask" name="subtask"
                        onChange="enableTheStartTime()">
                            <option value="Subtask">Subtask</option>
                    </select></td>
                </tr>
                <tr>
                    <td><input type="button" value="Start" name="Start" id="Start"
                        disabled/></td>
                    <td><input type="button" value="Stop" name="Stop" id="Stop"
                        disabled="disabled" /></td>
                </tr>
            </table>
        </div>
    </form>
    <script type="text/javascript" src="jsFiles/SampleJS.js"></script>
</body>
</html>

运行此程序时,默认情况下Start按钮不是disabled。我甚至试过disabled="disabled"

这很令人困惑,请让我知道我哪里出错了,我该如何解决这个问题

谢谢,

1 个答案:

答案 0 :(得分:0)

in else $('#Start').attr("disabled", false);设置开始按钮

if (stat == "start") {
       $('#Start').attr("disabled", true);
       $('#Stop').attr("disabled", false);

} else {
       $('#Start').attr("disabled", false);
       $('#Stop').attr("disabled", true);
}