Reputation: 9486
I want user to be able to scroll through select options with up/down arrows, but be able to press ctrl-c to copy from a matching input element whenever they want, seamlessly.
But I'm having trouble juggling the focus.
The best I've gotten is it works but I have to press down twice to move to the next select element.
Here is a fiddle I created, which isn't even populating the select box for some reason. Though it works on my server. On my server the picsarray
array is generated with PHP, but it should be the same effect as here.
https://jsfiddle.net/bbmqy0xm/2/
Upvotes: 0
Views: 892
Reputation: 11993
You can leave focus alone and just call select()
to highlight the text after you set it:
function showpicture(selectobj) {
/* deleted irrelevant js */
$("#image_name").val($(selectobj).val()).select();
}
https://jsfiddle.net/s4rmytt5/
Upvotes: 1