我正在通过数据库获取问题的值,我想编辑和更新问题的值。问题标题必须在 newEdit 或 fckeditor 中打开。由于所有值都来自数据库,但 nicEdit 仅加载第一次单击的问题标题的值,如果在此之后单击问题进行编辑,则它不会加载该特定问题的值,它显示先前加载的问题的值。我需要您的建议来加载每个问题的数据。
add_appraisal.jsp
<script type="text/javascript" src="ckeditor-small/nicEdit.js"></script>
<script type="text/javascript">
//Get the HTTP Object
function getHTTPObjectForBrowser(){
if (window.ActiveXObject)
return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else {
alert("Browser does not support AJAX...........");
return null;
}
}
function showQuestionList(e){
httpObject = getHTTPObjectForBrowser();
if (httpObject != null) {
httpObject.open("GET", "getAdminQuestion.action?sectionId="+e, true);
httpObject.send(null);
httpObject.onreadystatechange = showQuestionListResponse;
}
}
function showQuestionListResponse(){
if(httpObject.readyState == 4){
var res = httpObject.responseText;
jsonObj = JSON.parse(res);
var n = jsonObj.length;
$('#dyntable tr:not(:first)').remove();
for(i=0;i<n;i++){
var row = '<tr>';
var col = '';
col += '<td>'+(i+1)+ '</td>';
col += '<td>'+jsonObj[i].questionTitle+ '</td>';
/* col += '<td>'+jsonObj[i].questionContent+ '</td>'; */
col += '<td><a href="#myModal" onclick="editQuestion('+jsonObj[i].questionId+')" data-toggle="modal" class="editbutton">Edit</a> | <a class="btn confirmbutton_department" href="deleteQuestionAdmin.action?questionId='+jsonObj[i].questionId+'"> <small>Delete</small> </a></td>';
row = row + col + '</tr>';
$('#dyntable').append(row);
}
}
}
function editQuestion(e){
httpObject = getHTTPObjectForBrowser();
if (httpObject != null) {
httpObject.open("GET", "editQuestionAdmin.action?questionId="+e, true);
httpObject.send(null);
httpObject.onreadystatechange = showQuestionEditResponse;
}
}
function showQuestionEditResponse(){
if(httpObject.readyState == 4){
var res = httpObject.responseText;
jsonObj = JSON.parse(res);
document.getElementById("editQuestionContent").value = "";
document.getElementById("editQuestionTitle").value=jsonObj.questionTitle;
document.getElementById("editQuestionContent").value=jsonObj.questionContent;
document.getElementById("QuestionEditId").value=jsonObj.questionId;
new nicEditor().panelInstance('editQuestionContent');
/* new nicEditor({value : jsonObj.questionContent}).panelInstance('editQuestionContent'); */
}
}
</script>
<form method="post" action="updateQuestionAdmin.action">
<div style="width:100%;">
<table class="section_table">
<tr>
<td>
<div style="float:left; margin-top:3px;"><label>Question</label></div><div style="float:left;width: 90%;">
<input type="text" id="editQuestionTitle" name="questionTitle" class="input-large" value="1" style="width:90%;"></div>
</td>
</tr>
<tr>
<td>
<label>Question Heading</label>
<textarea id="editQuestionContent" style="width:650px; height:200px" name="questionContent"></textarea>
</td>
</tr>
</table>
</div>
<div class="modal-footer">
<input type="hidden" id="QuestionEditId" name="questionId" />
<button class="btn btn-primary" type="submit">Save</button>
<button data-dismiss="modal" class="btn">Close</button>
</div>
</form>