이 오류의 원인은 무엇입니까? element.value를 함수에 전달해야합니까? JSP로 설정하는 방법을 알고 있지만 JavaScript에서는 설정하지 않습니다. 값을 다른 함수로 전달하는 데 문제가 있습니다. 이것이 당신의 characterCounterEdit 함수가 호출 theonly 장소 인 경우'value.length'가 null이거나 객체가 아닙니다.
function editCommentToggle(id)
{
theRow = document.getElementById("id"+id);
//user = theRow.cells[0].innerHTML;
//date = theRow.cells[1].innerHTML;
com = theRow.cells[2].innerHTML;
idx = 2;
maxlength = 250;
// Comment field
cell = theRow.cells[idx];
while(cell.childNodes.length > 0)
cell.removeChild(cell.childNodes[0]);
element = document.createElement("textarea");
element.id="comments-"+id;
element.rows="3";
element.value = com;
element.style.width = "400px";
element.maxLength = "250";
element.onfocus = element.onkeydown = element.onkeyup = function(){
return characterCounterEdit(undefined, maxlength, element);
};
cell.appendChild(element);
function characterCounterEdit(id, maxLen, inputElement)
{
spanId = document.getElementById(id);
if (spanId)
{
// Update the counter the user sees.
var whatIsLeft = maxLen - inputElement.value.length;
if (whatIsLeft < 0) whatIsLeft = 0;
spanId.innerText = whatIsLeft;
}
// Restrict user from entering more than the maxlen.
**ERROR HERE-->>>** if (inputElement.value.length > maxLen)
{
inputElement.value = inputElement.value.substring(0, maxLen);
}
}
무엇이 질문입니까? 너 뭐 해봤 니? 우리는 자동화 된 코드 디버깅 기계가 아닙니다. –
나는 그 자체로 funtion에 "element"를 전달하려고 시도했다. –
적어도 영어 문장이 최소한으로 구성된 질문으로 돌아와주십시오. 가급적 오타가 있거나 구두점이없는 대신에주의와주의를 기울여야합니다. –