我想在这里发布表单数据表单 Javascript 我得到了两个值,我分配给了两个变量,现在我只需要从 javascript 文件中发布这两个值,但我无法将这些值分配到输入标签中
<div id="richTextArea" style="border: 2px solid rgb(40, 110, 89);width: 400px;height: 100%">
<iframe id="comments" name="comments" frameborder="0"
align="left" height="100%" width="100%"></iframe><br>
<input type="hidden" id=Task_ID value=<%= status_info[i].Task_ID%> name="Task_ID">
<button type="Submit" id=cmtSend title="Submit above Comment.." align="left" style="border: 2px solid rgb(40, 110, 89); width: 400px">Send</button>
</div>
cmtSend.addEventListener("click", function () {
var cmnt_Val = document.getElementById('comments').contentWindow.document.body.innerHTML
var task_ID = document.getElementById('Task_ID').value
//cmnt_Val having "welcome" and task_ID having 100001
if(cmnt_Val == ""){
alert("please enter the comment ...")
}
else {
alert(cmnt_Val)
let form = document.createElement('form');
form.action = '/StatusData';
form.method = 'Post';
form.innerHTML += '<input name="Comments" value=cmnt_Val>';
form.innerHTML += '<input name="Task_ID" value=task_ID>';
document.body.append(form);
form.submit();
}
}, false)
在这里,我单击提交按钮,我在控制台中得到以下结果
{ Comments: 'cmnt_Val', Task_ID: 'task_ID' }
守着一只汪
翻翻过去那场雪
相关分类