我正在尝试编写一个脚本,根据用户在上一页输入的内容禁用按钮。但是,当我直接将 disabled="disabled" 放入输入行时,我什至无法禁用按钮。当我在 .html 页面上输入下面完全相同的代码时,它工作正常并且按钮被禁用。我对网络开发很陌生,我不明白这里发生了什么。我指定<!DOCTYPE html>
并且按钮在<html>
标签内。知道为什么这个简单的命令不起作用吗?
<input type="button" id="b1" value ="How much can weight loss reduce my risk?" style="white-space:normal" disabled="disabled"/>
编辑:所有代码
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm3.aspx.vb" Inherits="WebApplication2.WebForm3" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="StyleSheet1.css" />
<title></title>
<style type="text/css">
#b1 {
height: 137px;
width: 137px;
}
</style>
</head>
<body>
<script type="text/javascript">
google.load("visualization", "1", { packages: ["corechart"] });
google.setOnLoadCallback(init);
function init() {
var data = google.visualization.arrayToDataTable([
['Years Out Risk', 'Risk'],
['5 Year Risk', <%= TKR5%>],
['10 Year Risk', <%= TKR10%>],
['15 Year Risk', <%= TKR15%>],
['20 Year Risk', <%= TKR20%>],
['25 Year Risk', <%= TKR25%>],
['30 Year Risk', <%= TKR30%>],
['Lifetime Risk', <%= TKRLife%>]
]);
var options = {
title: 'My Daily Activities',
'width': 400,
'height': 300,
animation: {
duration: 3000,
easing: 'out'
},
vAxis: {
viewWindowMode:'explicit',
viewWindow: {
max:1,
min:0
}
}
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
var button1 = document.getElementById('b1');
var button2 = document.getElementById('b2');
function drawChart() {
button1.disabled = true;
button2.disabled = true;
google.visualization.events.addListener(chart, 'ready',
function () {
button1.disabled = false;
button2.disabled = false;
});
chart.draw(data, options);
}
button1.onclick = function () {
data.setValue(0, 1, <%= nobTKR5%>);
data.setValue(1, 1, <%= nobTKR10%>);
data.setValue(2, 1, <%= nobTKR15%>);
data.setValue(3, 1, <%= nobTKR20%>);
data.setValue(4, 1, <%= nobTKR25%>);
data.setValue(5, 1, <%= nobTKR30%>);
data.setValue(6, 1, <%= nobTKRLife%>);
drawChart();
};
button2.onclick = function () {
data.setValue(0, 1, <%= TKR5%>);
data.setValue(1, 1, <%= TKR10%>);
data.setValue(2, 1, <%= TKR15%>);
data.setValue(3, 1, <%= TKR20%>);
data.setValue(4, 1, <%= TKR25%>);
data.setValue(5, 1, <%= TKR30%>);
data.setValue(6, 1, <%= TKRLife%>);
drawChart();
}
drawChart();
}
</script>
<div id="chart_div"></div>
<input type="button" id="b1" value ="How much can weight loss reduce my risk?" style="white-space:normal" disabled="disabled"/>
<input type="button" id="b2" value ="Reset risk" style="white-space:normal"/>
</body>
</html>