0

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>

1 Answer 1

0

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();
2
  • Still not working. For some reason the value field is not being populated and it's just blank when checking properties.
    – casao01
    Jan 29, 2020 at 20:31
  • var TextField1 = document.getElementsByName("reason"); TextField1[0].setAttribute("value", ""); TextField1[0].value = "TEST"; var FormSub = document.getElementsByName("profileForm"); FormSub[0].submit();
    – casao01
    Jan 29, 2020 at 20:36

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.