Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将文本添加到文本区域的JS添加按钮不起作用_Javascript_Html_Servicenow - Fatal编程技术网

Javascript 将文本添加到文本区域的JS添加按钮不起作用

Javascript 将文本添加到文本区域的JS添加按钮不起作用,javascript,html,servicenow,Javascript,Html,Servicenow,这些文本区域字段位于servicenow页面上: <textarea id="activity-stream-comments-textarea"></textarea> <textarea id="incident.close_notes"></textarea> 添加注释的选项工作正常(添加到id值为活动流注释textarea的textarea) 但是,添加解决方案注释(到ID事件。关闭注释)的选项不起

这些文本区域字段位于servicenow页面上:

<textarea id="activity-stream-comments-textarea"></textarea>
<textarea id="incident.close_notes"></textarea>
添加注释的选项工作正常(添加到id值为
活动流注释textarea
的textarea)

但是,添加解决方案注释(到ID
事件。关闭注释)的选项不起作用

与中一样,我单击按钮添加一个解决方案注释,该注释的添加方式与使用AddNote函数添加的方式不同。单击按钮添加解决方案注释时,在控制台中看不到任何错误

我知道文本区域的ID对于分辨率字段是正确的

我唯一想知道的是,添加解决方案注释的选项不起作用,因为ID包含一个点,而活动注释的ID不包含一个点


我曾尝试单独使用resolution选项进行测试,以隔离与AddNote函数的任何冲突,但没有任何区别。

您的假设是正确的,导致问题的点add
\
将解决您的问题

var text\u resolve=“症状\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~n\n解决方案\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n”;
//为添加分辨率注释的选项创建输入元素
var inputResolve=document.createElement(“输入”);
inputResolve.type=“按钮”;
inputResolve.value=“解析”;
inputResolve.onclick=AddResolve;
inputResolve.setAttribute(“类”,“btn btn默认btn参考图标图标信息”);
setAttribute(“样式”,“位置:绝对;顶部:160px;右侧:40px;宽度:120px”);
document.body.appendChild(inputResolve);
//AddResolve函数-将注释添加到活动更新文本区域
函数AddResolve(){
if(!$(“#事件\\.close_notes”).val()){
$(“#事件\\.close_notes”).val(文本解析);
$(“#事件\\.close_notes”).css({'background-color':'green'});
$(“#事件\\.close_notes”).focus();
}
}

// text values for update and resolve strings
var text_update = "Last Action\n~~~~~~~~~~~~~~~~~~~~~~\nOn " + today + " I \n\nNext Action\n~~~~~~~~~~~~~~~~~~~~~~\nWait for reply\n\nNext Action Date\n~~~~~~~~~~~~~~~~~~~~~~\nNot known - review in 7 days if no update before then from customer.";

var text_resolve = "Symptoms\n~~~~~~~~~~~~~~~~~~~~~~\n\n\nCause\n~~~~~~~~~~~~~~~~~~~~~~\n\n\nSolution\n~~~~~~~~~~~~~~~~~~~~~~\n\n";

// create input element for the option to add an activity note
var inputNote=document.createElement("input");
inputNote.type="button";
inputNote.value="Add Note";
inputNote.onclick = AddNote;
inputNote.setAttribute("class", "btn btn-default btn-ref icon icon-info");
inputNote.setAttribute("style", "position:absolute; top:120px; right:40px; width:120px");
document.body.appendChild(inputNote);

// AddNote Function - add the note to the activity update textarea
function AddNote() {
    if (!$("#activity-stream-comments-textarea").val()) {
        $("#activity-stream-comments-textarea").val (text_update);
        $("#activity-stream-comments-textarea").css({'background-color':'yellow'});
        $("#activity-stream-comments-textarea").focus();
    }
}

// create input element for the option to add  resolution note
var inputResolve=document.createElement("input");
inputResolve.type="button";
inputResolve.value="Resolve";
inputResolve.onclick = AddResolve;
inputResolve.setAttribute("class", "btn btn-default btn-ref icon icon-info");
inputResolve.setAttribute("style", "position:absolute; top:160px; right:40px; width:120px");
document.body.appendChild(inputResolve);

// AddResolve Function - add the note to the activity update textarea
function AddResolve() {
    if (!$("#incident.close_notes").val()) {
        $("#incident.close_notes").val (text_resolve);
        $("#incident.close_notes").css({'background-color':'green'});
        $("#incident.close_notes").focus();
    }
}