I'm waiting for user input like this:
prompt('hello', 'world');
I don't understand why my prompt defaultText 'world' is selected.
Not a big deal, just curious, but I'd like to focus on first character without selection.
Is there some kind of placeholder for javascript prompt box or a way to do it (in pure javascript) ?
Well, it's a UX feature. The default is "world" but if I wanted to override it, I can just start typing, it saves me from selecting all of it. If I wanted to append to it, all I need to do is press the left arrow.
prompt(text,defaultText)
The default input text shown as selected to save user time to override it easily. All browsers are doing same except Safari.
Related
My job is to order diagnostic tests for patients and I need to write 6-7 characters value for each diagnostic test. I have 24 different values and I need to fill it many thousands of times. I am thinking to create 24 different scripts with Tampermonkey to speed up my job by clicking on the script box.
So the thing is that I need to fill this
box. Here are the input id and everything of that box in the console. Then I type the value manually, I get popup list which updates every time I type one character (same principle as google or youtube search box), here is the popup list after I type a value and if I want that diagnostic test, I need to click on it from the popup list, I cannot just simply click enter. So this is the code I have to fill the box by a value:
document.body.appendChild(element)
element.addEventListener('click', function(){
document.querySelector("input#generic_test_order_search.ui-autocomplete-input").value = '15002 '
})
The script fills the value, but the popup list doesn't appear and I need to click on the box, delete one character and write it again to get a list and then to choose a diagnostic test from it. Still, time-consuming.
I wonder, is it possible to make a script to add automatically a diagnostic test from the list like this example? If no, is it somehow possible to make that popup list would appear and I won't need to click on the box, delete one character and write it again? At least, could I make that the box is clicked after a value has been filled? I tried this code but doesn't work: document.querySelector("input#generic_test_order_search.ui-autocomplete-input").click()
Please help me to make it as automatic as possible, which would save me hundreds of hours in the long-term.
1 - As for the second part of the question. Picture 4.
It is pretty simple to make an auto-fill for the dropping parametres, we just might need the html-code of the elements.
For example,
document.getElementsByTagName('input')[0].click(); clicks the first input checkbox from the first input
document.getElementsByTagName('select')[0].selectedIndex = 1; selects the second value from the first select
document.getElementsByTagName('button')[0].click();clicks the first button
To make it more precise you might use class at first, at then tag:
document.getElementsByClassName('testClassDependingOnExistingClasses')[0].getElementsByTagName('button')[0].click(); for example.
Anything you do manually on a page like that can be done automatically with JS.
2 - As for the first part of the question. Picture 2.
Here is the part of the answer.
How to trigger arrow down press in js?
Maybe this code might help, but not enough information, since no data on html-code of the dropped elements.
document.getElementById('generic_test_order_search').clildren[0].click();
I have the following question: let's suppose I copy some text from first browser tab and then I want to paste this text in textbox located in second browser tab. Is it possible to detect in whicxh tab pasted text was copied? Thank you in aadvance
Simple answer: no, this is not possible.
The exception is when you have control over the pages in all tabs and watch for the pasting.
well,I am thinking that you could detect onKeyPress() "ctrl+c" for each element. it only works for key press though not "right-click+copy". next, how do you want to pass it to second browser? you will have to pass the value to server first then to second browser. perhaps with socket.io..
I don't think the second browser can simply paste it.. not with ctrl+v nor with rightclick+paste.. but the copied-value is there, perhaps you might have to provide your own button which will make use of this value
When im writing on chrome for example (got to work on all browsers) on the textarea in my site, and im pressing CTRL+Z, its deleting everything i wrote until the last "/n". Is there any way that i could make javascript save texts, so when a user will press CTRL+Z its will go to the last point when javascript saved the data?
For example, i would love to save the data every time a user click on backspace or a button that changes the textarea. its preety similar to the undo, redo buttons on stackoverflow.
Some kind of a string list isnt good for me, im looking for a built javascript/jquery way of doing that, if there is any.
You can have a look in this library
http://dmauro.github.io/Keypress/
It's allow you to detect all input, so basically you can store it on any letter typed, or at least save the text in the textarea everytime a special key is pressed.
It's also really easy to detect combo.
Hope that's help
has anyone ever seem an autocomplete solution in JS that works like Chrome's Console? (I think this is in version 17+)
I am trying to build something using jQuery, but I can't imagine how the autocomplete placeholder that stays below the active text follows the cursor.
All the autocomplete thing, the search, sort, etc... I've already done, I just need a way that the placeholder follows the cursor. Thanks.
Well, why not to use a text box and to call function on any key press/key down. Then the function will read the text that is currently enter and check your data structure for possible end of the word.
You can sort the possible answer and to write the first one for example with other color. If the user press space or enter to color the whore world with black, and if it is press tab to switch with other possible answer...
Do you mean this?I can write some code to show you want I mean if this is what you need?
My web-based app allows users to override values in certain textboxes. If they don't override the value, the system will display (and use) a default.
I would like to support a scenario where the user has overridden the value, but now wants to revert back to the system default value, but doesn't know what value to enter. I would like to provide an intuitive UI for causing the system to revert the field's value back to its default. Does anyone have any suggestions?
Fields occur both on edit forms (where space is plentiful), as well as on edit grids (where space is scarce).
Requiring the user to clear the field is not an option, as sometimes the user's override is an empty value. Would rather not use a keystroke, like Ctrl-Z or ESC.
Best thing I can think of is the user hovers over the field and a popup displays giving the user the option to use the system default. I could use the same popup to capture/display a comment related to the override.
I've used a 'rewind' type icon after a textbox (like an arrow in a circle that points backwards) where there is plenty of space to allow a user to revert to the default or original version.
Also used grey text to show the default - which disappears (using a keyup event) as the user overwrites.
If space is short your popup sounds like a good idea.
How about
<input type="text" value="Enter text here, a space will clear it"
onfocus="this.title='Clear field to revert to '+this.defaultValue"
onblur="if (this.value=='') this.value=this.defaultValue;
else this.defaultValue=this.value" />
I always suggest to look at how others have solved a UX problem before deciding on an answer. Ask yourself what applications (web or otherwise) have supplied default values and allowed you to revert back to them.
I think the problem you're likely trying to solve is not the interaction of reverting to default values, but rather, to inform users what the default values are. If this is the case I would lean away from a button and towards inline help.
Hope this helps.
-
Nik.ca