我正在尝试创建这个程序,以便当您单击按钮 1 时,它将运行函数 firstClass。不太清楚为什么它不起作用。
HTML:
<form onSubmit="return firstClass();">
<h1>Click "1" for first class seats. Click "2" for economy class seats</h1>
<button type="submit">1</button>
</form>
Javascript:
var seatArray = [ , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var first = 1;
var economy = 6;
function firstClass()
{
if (first <= 5 && seatArray == 0)
{
window.alert("You have chosen First Class. You have been given seat number: ");
}
else
{
window.alert("Seats are full");
}
return false;
}