shortkeys
shortkeys copied to clipboard
Using JS to click button
I'm trying to get shortkeys to fire some JS to click a button on our warehouse management system.
One button is , there are other submit buttons on the page but only one with that value
<input type="submit" value="Create Shipment" class="btn btn-success pull-right">
The other is as below, the link on this changes for every order
<a class="btn btn-success" href="/Picking/DespatchOrder?OrderId=13413">Despatch</a>
Any help appreciated!
I need the same thing! To click an Edit button.
@ggbblimited According to a review this should work:
Just need to find that "button" from a page by right clicking it, inspect, copy JS Path, then use javascript document.querySelector("#NameofButton").click() and it worked magic for me!
I haven't gotten it to work...
I found the issue with mine. It was a conflicting extension. :( But I need that extension! ACK.
Andddd in this conversation with myself. I got it to work. Forgot that I was working on a Chromebook and my keys were different. Duh.
Andddd in this conversation with myself. I got it to work. Forgot that I was working on a Chromebook and my keys were different. Duh.
I've got one going by class name
document.getElementsByClassName('btn btn-success pull-right')[0].click();
But I have another that shares the same class with other buttons, and the other script I have for finding by inner text isn't working
Correction, fixed it.
/* Click button by innerHTML text */
function AutoClickBtnByValue() {
var button = document.getElementsByClassName("btn-success");
for (var i = 0; i < button.length; i++) {
if (button[i].innerHTML.indexOf('Despatch') > -1) {
button[i].click();
console.log('Success! Clicked button' + i + ' with value: "click me now" ');
}
}
}
setInterval(AutoClickBtnByValue, 2000);