问候开发人员,目前我正在学习JavaScript。我尝试做两个按钮,一个用于添加,另一个用于取消禁用。一旦单击添加它显示提示框输入主题。输入主题后,unfriend框应该能够单击并添加按钮disable。我的问题是现在我的所有功能都不起作用。按钮仍然相同。我认为这是由于form.developers请帮助我知道我在编码方面的错误。
function disableButton(btn) {
var subject = prompt("Please enter Subject that want to study");
if (subject != null) {
form['subject'].value = subject;
document.getElementById("btn").disabled = true;
document.getElementById("add").disabled = false;
document.getElementById("btn").value = "request sent";
}
}
function disableButton(add) {
document.getElementById("add").disabled = true;
document.getElementById("btn").disabled = false;
document.getElementById("btn").value = "Add friend";
form.submit();
}
<html>
<body>
<form method="post" id="form" enctype="multipart/form-data" autocomplete="off" onSubmit="disableButton(btn);return false;">
<input type="hidden" id="subject" name="subject" />
<input type="submit" value="unfriend" id="add" onClick="ableButton(add)" disabled/>
<input type="submit" value="add" id="btn" id="btn" />
</form>
</body>
</html>