Question

3
Replies
2705
Views
Close popover
Mark Porter (MarkP977)
Nationwide

Nationwide
GB
MarkP977 Member since 2017 16 posts
Nationwide
Posted: May 21, 2018
Last activity: May 23, 2018
Closed

Robotics - Using Javascript - send Enter key to text box

I am creating an automation in a web database with a search box that does not have a search button. The only way to trigger the search function is to hit enter in the text box. I am using the following javascript which compiles but does not achieve the enter press. Any ideas or suggestions would be greatly appreciated:

function os_RaiseEvent(eventname)
{
var element = document.querySelector('[id$="_text"]');
var event;
if(document.createEvent)
{
event = document.createEvent("HTMLEvents");
event.initEvent(eventname, true, false);
if(eventname == "keydown" || eventname == "keyup")
{
event.keyCode = 13;
}
element.dispatchEvent(event);
}
else if(document.createEventObject)
{
event = document.createEventObject();
if(eventname == "keydown" || eventname == "keyup")
{
event.keyCode = 13;
}
element.fireEvent("on" + eventname, event);
}
return true;
}

Data Integration Java and Activities Robotic Process Automation
Moderation Team has archived post,
Close popover This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Question, please write a new Question.