<script>
var data = prompt("What year would you like the data for?");
if (data == 1901) {
alert("26 thousand per million for males and 23 for females ");
} else if (data == 1910) {
alert("23 thousand per million for males and 18 for females");
} else if (data == 1920) {
alert("19 thousand per million for males and 15 for females");
} else if (data == 1930) {
alert("17 thousand per million for males and 14.5 for females");
} else if (data == 1940) {
alert("20 thousand per million for males and 15 for females");
} else if (data == 1950) {
alert("15 thousand per million for males and 11 for females");
} else if (data == 1960) {
alert("14.5 thousand per million for males and 9.5 for females");
} else if (data == 1970) {
alert("14 thousand per million for males and 8 for females");
} else if (data == 1980) {
alert("13 thousand per million for males and 5 for females");
} else if (data == 1990) {
alert("10 thousand per million for males and 6 for females");
} else if (data == 2000) {
alert("7 thousand per million for males and 5.2 for females");
} else if (data == 2010) {
alert("7 thousand per million for males and 4.9 for females");
}else alert ("please enter a valid year from the chart.");
</script>
这是我的 javascript,它显然会打开一个提示并请求一个日期,但我希望这个提示在单击按钮时变为活动状态
获取日期 [CLICK HERE] -----> “您想要哪一年的数据?”
我该怎么做。这个按钮也需要进入 html。