【发布时间】:2017-02-23 03:13:19
【问题描述】:
我有一个显示多个文本区域的模式,我想要禁用已提交的特定文本区域
我有这个 javascript 函数,但它不起作用,我将行 id 连接到 textarea id,以便我可以定位特定的 textarea。我不知道我哪里出错了,请帮忙。
function approveStatus(status){
var nid = status;
var note = 'APPROVE';
var app = document.getElementById("approvenote");
app.addEventListener("click", function(){document.getElementById("note-"+status).disabled = true;});
$.ajax({
type: "POST",
url: "mod.note.php?n=add",
data: "note="+note+"&nid="+nid
});
}
html
<textarea class="from-control" rows="4" cols="50" id="note-<?php echo $row1['objID']; ?>"
name="note"></textarea>
<button type="button" class="btn-xs btn-warning"
onclick="makeStatus(<?php echo $row1['objID']; ?>)" id="submitnote" name="submitnote">Submit Note
</button>
</form>
<button type="button" class="btn-xs btn-info"
onclick="approveStatus(<?php echo $row1['objID']; ?>)" id="approvenote" name="approvenote" >APPROVE</button>
php
$app = isset($_GET['n'])?$_GET['n']:'';
if($app=='add'){
$remarks = $_POST['note'];
$note_id = $_POST['nid'];
$auth_user->lessonRemarks($remarks,$note_id);
header("Location: admin.php");
}else{
header("Location: admin.php");
}
php函数
public function lessonRemarks($remarks,$note_id){
$stmt = $this->conn->prepare("UPDATE `objectives`
SET `status` = :remarks
WHERE `objID` = :note_id");
$stmt->bindparam(":remarks",$remarks);
$stmt->bindparam(":note_id",$note_id);
$stmt->execute();
return $stmt;
}
【问题讨论】:
-
发布您的相关
html以及您在哪里调用此approveStatus -
您正在使用 onclick 以及为同一 ID 添加事件侦听器。所以使用 "document.getElementById("note-"+status).disabled = true;"而不是 "app.addEventListener("click", function(){document.getElementById("note-"+status).disabled = true;});"
-
@MichaelSeltene 完美回答先生!这就是我要找的,非常感谢
-
欢迎。我很高兴我能帮上忙。我会把它作为答案。
标签: javascript jquery html ajax bootstrap-modal