无法填写文本字段并自动提交 [英] Unable to fill out the text field and submit automatically
问题描述
我想要完成的是使用 Tampermonkey 用单词TEST"填充访问原因"的文本框.(我对使用 Tampermonkey 和 UserScript 还很陌生,所以请耐心等待.)
我遇到了一个问题,即访问原因"仍为空白且未自动提交.
你能提供帮助吗?如果您需要什么,请告诉我.
这是我的用户脚本:
function ClickURL2() {var FillF2 = document.getElementsByName("reason");FillF2[0].value = "TEST";var FormSub = document.getElementsByName("crm-info crm-dialogue");FormSub[0].submit();}
这是网页的来源:
<div class="crm-form-container"><div class="crm-profilefield"><div class="field-label"><span class="audited" title="适用于网守用户">†</span><span class="required" title="Required">*</span>访问原因</div><div class="field-input"><input class="" type="text" name="reason" required="required" title="" style="">
<div class="ui-helper-clearfix"></div></div><input type="submit" class="hidden" style=""></div>
</fieldset></表单>
当使用 javascript 提交表单时,您应该在表单元素上使用 submit().我测试了其他代码,它似乎将值添加到文本框就好了.
var FormSub = document.getElementsByName("profileForm");FormSub[0].submit();
What I am trying to accomplish is to populate the text box for "Reason for Access" with the word "TEST" using Tampermonkey. (I'm very new to using Tampermonkey & UserScript so please be patient with me.)
I am having an issue where the "Reason for Access" is still blank and isn't submitting automatically.
Would you be able to provide assistance? Let me know if you need anything.
This is my userscript:
function ClickURL2() {
var FillF2 = document.getElementsByName("reason");
FillF2[0].value = "TEST";
var FormSub = document.getElementsByName("crm-info crm-dialogue");
FormSub[0].submit();
}
This is the source of the webpage:
<form name="profileForm">
<fieldset>
<div class="labelGroup">
<div class="crm-legend">
<span class="required" title="Required">*</span> = Required<br>
<span class="audited" title="Available to Gatekeeper Users">†</span>
= Available to Gatekeeper Users
</div>
<div class="crm-form-container">
<div class="crm-profilefield">
<div class="field-label">
<span class="audited" title="Available to Gatekeeper Users">†</span>
<span class="required" title="Required">*</span>
Reason for Access</div><div class="field-input">
<input class="" type="text" name="reason" required="required" title="" style="">
</div>
<div class="ui-helper-clearfix"></div></div><input type="submit" class="hidden" style=""></div>
</div>
</fieldset>
</form>
When submitting the form with javascript, you should be using submit() on the form element. I tested the other code and it seems to add the value to the textbox just fine.
var FormSub = document.getElementsByName("profileForm");
FormSub[0].submit();
这篇关于无法填写文本字段并自动提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!