Javascript 脚本未执行且脚本不工作
我不熟悉编码,我试图创建一个“预订表”,让人们填写他们的详细信息来预订游戏。 我编写了一些脚本,当用户单击按钮时显示游戏的名称和ID 但是(猜怎么着!)它不起作用 非常感谢您的帮助。 多谢各位Javascript 脚本未执行且脚本不工作,javascript,Javascript,我不熟悉编码,我试图创建一个“预订表”,让人们填写他们的详细信息来预订游戏。 我编写了一些脚本,当用户单击按钮时显示游戏的名称和ID 但是(猜怎么着!)它不起作用 非常感谢您的帮助。 多谢各位 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://ww
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Games Library Reservations Page</title>
</head>
<body>
<div>
<h1>Reservations</h1>
</div>
<p><b>Wish to reserve a game? Just fill in this form:</b> </p>
<form name="reservationsForm">
<p><strong>Game ID</strong><br>
<input type="number" name="gameID" placeholder="1-8">
<button type="button" onclick="gameConfirmation()">Reserve a game!</button>
<p id="gameChosen"></p>
</form>
</div>
<script>
function gameConfirmation()
var id;
id = document.getElementById("gameID").value;
if (id == 1) {
document.getElementById("gameChosen").innerHTML = "You have selected to ``reserve game ID 1: Fantasy World.";
} else if (id == 2) {
document.getElementById("gameChosen").innerHTML = "You have selected to reserve game ID 2: Sir Wags A Lot.";
} else if (id == 3) {
document.getElementById("gameChosen").innerHTML = "You have selected to reserve game ID 3: Take A Path.";
} else if (id == 4) {
document.getElementById("gameChosen").innerHTML = "You have selected to reserve game ID 4: River Clean Up.";
} else if (id == 5) {
document.getElementById("gameChosen").innerHTML = "You have selected to reserve game ID 5: Pinball.";
} else if (id == 6) {
document.getElementById("gameChosen").innerHTML = "You have selected to reserve game ID 6: Ghost Girl.";
} else if (id == 7) {
document.getElementById("gameChosen").innerHTML = "You have selected to reserve game ID 7: Dress Up.";
} else if (id == 8) {
document.getElementById("gameChosen").innerHTML = "You have selected to reserve game ID 8: Where is my hat?.";
} else {
document.getElementById("gameChosen").innerHTML = "There is no game with that ID. Please try again.";
}
}
</script>
</div>
</body>
</html>
游戏库预订页面
保留地
想预订一场比赛吗?只需填写以下表格:
游戏ID
预定一场比赛!
函数gameConfirmation()
变量id;
id=document.getElementById(“gameID”).value;
如果(id==1){
document.getElementById(“GameSelected”).innerHTML=“您已选择``保留游戏ID 1:幻想世界'。”;
}else if(id==2){
document.getElementById(“GameSelected”).innerHTML=“您已选择保留游戏ID 2:爵士摇摆了很多。”;
}else if(id==3){
document.getElementById(“GameSelected”).innerHTML=“您已选择保留游戏ID 3:获取路径。”;
}else if(id==4){
document.getElementById(“GameSelected”).innerHTML=“您已选择保留游戏ID 4:河流清理。”;
}else if(id==5){
document.getElementById(“GameSelected”).innerHTML=“您已选择保留游戏ID 5:弹球。”;
}else if(id==6){
document.getElementById(“GameSelected”).innerHTML=“您已选择保留游戏ID 6:幽灵女孩。”;
}else if(id==7){
document.getElementById(“GameSelected”).innerHTML=“您已选择保留游戏ID 7:装扮。”;
}else if(id==8){
document.getElementById(“GameSelected”).innerHTML=“您已选择保留游戏ID 8:我的帽子在哪里?”;
}否则{
document.getElementById(“GameSelected”).innerHTML=“没有具有该ID的游戏。请重试。”;
}
}
如果调用getElemEntById,您还需要设置一个ID,添加
,是的,在函数声明后缺少一个{。如果调用getElemEntById,您还需要设置一个ID,添加
,是的,您缺少一个{在函数声明之后。如果调用GetElemEntById,还需要设置一个ID,添加
,是的,在函数声明之后缺少一个{。如果调用GetElemEntById,还需要设置一个ID,添加
,是的,缺少一个{在函数声明之后。您缺少函数-function gameConfirmation()的开始括号-在参数列表之后添加{missing{
。检查浏览器的错误日志,应该会发现语法错误。感谢各位,感谢!您缺少函数-function gameConfirmation()的开始括号-在参数列表后添加{Missing{
。检查浏览器的错误日志,该日志应已捕获语法错误。感谢各位,非常感谢!您缺少函数的开头括号-函数gameConfirmation()-添加{Missing{
在参数列表之后。检查浏览器的错误日志,该日志应该已经捕捉到语法错误。感谢各位,感谢!您缺少函数的开头括号-函数gameConfirmation()-添加{missing{
在参数列表之后。检查浏览器的错误日志,它应该已经捕捉到语法错误。谢谢大家,谢谢!