0

I have the following input control in an ASPX page:

<input tabindex="0" class="_f_ql _f_rl textbox allowTextSelection placeholderText" role="textbox" aria-labelledby="MailCompose.SubjectWellLabel" autoid="_f_B2"></input>

I am only able to inject JavaScript into this page, and check if an input element with the above class is present, and I would like to change the value of the text that is inside of this textbox. Is there any way to do this with JavaScript?

So far, I can get the correct element using the following code, but setting the value on it does not work to set the textbox's text to Testing...:

var subjectElements = getNodeElementsContainingID(document.body, "_f_ql _f_rl textbox allowTextSelection placeholderText");
if (subjectElements.length > 0) {
    subjectElements[0].value = "Testing...";
}

I don't want to inject jQuery as its overkill, but seeing as how I have the element I need, what can I do to it to set the text value on it?

1 Answer 1

1

Try

document.getElementsByClassName('_f_ql _f_rl')[0].value = 'Testing...';
Sign up to request clarification or add additional context in comments.

1 Comment

Ah, damn it, the class threw me off, well done man! Saved me so much time. It wasn't the ID, I don't even know why I read it as an ID!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.