Mozilla firefox problem in javascript - firefox

how i can get (if)any text is selected in textbox and i want to get it in any variable of javascript.... specifically for Mozilla firefox...?
the above description is not enough so let me give completely the definition.. My Extension of firefox is an Extension that double clicks any word from the webpage and finds its possible meaning from database... so user can even write anything in Textbox and double click the same for finding its meaning.. so please do suggest any way to complete selection from textbox's selected text....? in addition i am already using dblclick event handler so dont suggest that solution.... Also the problem is that the web page can be any site's webpage so even the textarea or any control is specific tho that page how could i slice the text from it than ...Thanxx in advance....

You can use document.getSelection() which returns a selection object containing the currently highlighted text in the document. However, calling it at the right time can be tricky. You can't do it from an onclick handler on a button, for instance, because by the time the onclick handler fires, the selection's focus has been removed from the text and moved to the button.

Use the selectionStart and selectionEnd properties e.g.
var selectedText = textbox.value.slice(textbox.selectionStart, textbox.selectionEnd);

Related

Is it possible to hide the ContextualBalloon without removing the view from the DOM?

I have a situation where a toolbar item in CKEditor5 opens a ContextualBalloon which contains an iframe.
In my current understanding, the only way to hide the balloon is to remove the iframe view i.e.
this.balloon.remove(this.colorPickerIframeView)
However this removes the iframe view from the DOM, meaning that the next time I open the balloon view the iframe is reloaded.
I'd rather not have to reload the iframe every time, is there any way around that?
If you want to only hide the ContextualBalloon's view you can try to use this.balloon.view.hide()

Watir clicking nested elements inside a container

I'm trying to complete a happy path e-commerce payment test but I cant seem to click on the nested element for credit card to be honest I'm not entirely sure which is the clickable element.
Any help to get this working would be appreciated.
When inputting forms, you typically want to interact with input and select elements. In this case, you can see that the visible input field is a radio button - ie <input type="radio">.
You access radio buttons using the radio method and select it by using the set method:
browser.radio(id: 'cc-payment').set
The element you want to click is the input with type radio. You should be able to do something like:
driver.find_element(:css, "input[id='cc-payment'][value='creditCard']").click
I'm curious if clicking on the parent item would resolve.
#browser.input(id: 'cc-payment').parent.click
If the div registers the click and sets the input then this might work. You should be able to manually verify this beahviour by clicking outside of the radial and seeing if it selects.

Get value from autocomplete text field in ApEx

I want to create a dynamic action, that will set a value to an item on the page, when the value of another item (autocomplete text field) is set.
So the proccess goes like this:
Click on the autocomplete field
type some letters
choose one of the suggested values
I cannot find an event that will be executed when the selection of one of the suggested values happens. This way, I cannot see how I can read the value of the autocomplete field, once a suggested value is selected.
The change event doesn't fit my needs, it doesn't execute when one suggested value is selected.
I had the same problem, found this link: https://community.oracle.com/thread/2130716?tstart=0 and modified my dynamic action as follows to get the desired behaviour:
Event = Custom
Custom Event = result
From the link:
the problem seems to be the default behavior of the browser. When you
enter some text into the autocomplete and the list is displayed, the
focus is still in the text field. Also if you use the keyboard cursors
to pick an entry the focus will still be in the textfield. That's why
the change event of the textfield doesn't fire. It only fires if you
leave the field.
On the other side if you pick an entry with the mouse, the browser
will remove the focus from the text field for a moment (before the
JavaScript code puts the focus back), because you clicked outside of
the field. But that's enough so that the browser fires the change
event.
I had a look into documentation of the underlaying jQuery Autocomplete
widget
(http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/) and
there is actually an event called "result" which can be captures if an
entry is selected from the drop down list.
Try "Lose Focus" as event. It will trigger your dynamic action when you leave the autocomplete field, i.e. your curosr is moved to another field.
This probably depends on the APEX version you are using.
In case of 18.2, because the underlying component is based on Oracle JET's "inputSearch" component, you need to use following configure to capture the select change event for text with autocomplete:
event: Custom
custom event: ojupdate
Reference:
https://docs.oracle.com/cd/E87657_01/jet/reference-jet/oj.ojInputSearch.html#event:optionChange
I turned on the browser console, then turned ApEx Developer toolbar debug, and found that, on the contrary, the "Change" event does fire upon user clicking with the mouse on one of the selections. However if the user uses keyboard (type a few letters to narrow the list down, then use down arrow key to arrive at desired value, then press enter) then the Change event does not fire, just as you say.
Moreover: even when you do get the value sent back via mouse-click initiated Change event, the value isn't the autocomplete's complete and valid value, but instead the possibly partial and wrong-case value just as typed by the user. I.e., the the change event's submission of the value precedes the autocomplete's substitution.
The answer that #VincentDeelen gave is the best alternative that I can see, although it doesn't quite give that "instantantenous synchronicity" feel. You could maybe use the "Key Down" event, but be careful with that. You could get a really excessive amount of web and db traffic as each and every keystroke (including corrections) results in another firing of the dynamic action.
Testing environment: ApEx 4.2.3 with Chrome 33 as well as IE 9.
p.s. This might be worth a mention to the ApEx development team as well.
It's not really ideal, but you could use onfocus(). I'm looking for the same thing you are, I think, a custom event that fires when the selection of a suggested value happens. I haven't found it yet though and that is my work-around for now. It will run whatever function you've created for this initially with no value, but once the selection is made it will return focus and run the function again with the right value. Like I said, not ideal but it works.
Jeffrey Kemp is right. You can set it up through a dynamic action using the custom event, result. You can also register it on page load using document.getElementById("{id}").addEventListener("result", {function}); or $("#{id}").result( function( event, data, formatted ) { //something here });.
Oracle apex 19 now added a "component event" when you create a dynamic action called "Update [Text Field with autocomplete]" - this action is fired when you select a value from the list, but not when you leave the field (similar to adding the custom event "ojupdate").

innerHTML problem in FF, Chrome. IE is fine

i have a page where inputs are loaded dynamically on button press.
When the button is pressed, I add the source code to the innerHTML of the container element.
So if you press it it once it will contain .
if you press it again, it will add a second one, with name 'inp-2'.
The problem is that if you add one input, you fill it in with some text, then you press the add button again, the inserted text will gone, because - at least i think so - it keeps the original innerHTML, which does not contain the inserted text. This is happening in FF, Chrome. in IE it is working fine, because the innerHTML of the IE is updated by the user's interactivity; if you fill in an input then you view the source code, then you will see your text is in the input's value attribute, not like in FF or Chrome.
What do you suggest, how can this be solved in the most quick and efficient way? Keep in mind that I have simplified the code to a single input, but for each press of the button, a huge source code is added to the innerHTML (1 table containing trs, tds, about 9 inputs and text). thanks
If you want to continue using .innerHTML, instead of DOM methods that will actually append nodes, you will need to add "change" event handlers to those inputs. The browser is not required to synchronize the value attribute and the value property of the <input/>, but your event handler can do that in a cross-browser way.
Try something like this. The innerHTML should be updated each time the attribute is updated.
node.innerHTML += '<input name="inp-#" value="starting_value" onchange="this.setAttribute(\'value\',this.value);" />';

How to make autocompleting textbox in VB6?

I want to have an auto-completing textbox like the one in the image below:
This screenshot is from an accounting software. Whenever the user focuses on a textbox and starts typing something, the suggestions just pop up under the control (as seen in the image under the Purc type textbox). This auto-suggest functionality even works in the cells of the grid shown in the picture. Moreover, the fields in which this auto-suggest is enabled allow only values from the auto-suggest list to be filled up and nothing else.
I want to emulate similar functionality in my app in VB6. Any ideas on how to implement auto-completing textbox in VB6?
Checkout the AutoComplete Text Box at FreeVBCode.com.
Another option is at VBNet. The article shows how to use shlwapi.dll api.
What I've typically done is do what is included in the project link by C-Pound Guru. Take a TextBox and as the user types into the field have a ListBox fill with results matching the text. The ListBox would by default be hidden but will be made visible when text is entered into the field. When the ListBox is clicked then simply update the TextBox with the ListBox's selected item text then hide the ListBox control again. A quite simple routine to complete.
VBAccelerator is an excellent site for VB6 tips - try their AutoComplete sample

Resources