Hello Team, question regarding the cursor position in the LOV component.

We have a default value (%) which we put into the search field. In the code it would be something like that: api_lov.setSearchField('AIRP', 'airp_lov1.code', '%');

After that we perform the query execution: api_datasource.executeQuery('airp_lov1');

And then we show the LOV: api_lov.show('AIRP')

The cursor position is set to be after the percent sign (%) (can't upload file because of insufficient carma).


The issue is that in the most cases people search by the first symbol and they need to perform an additional step to move the cursor before the percent sign.

Is there any way to place the cursor at the start of the input?

Thanks and best regards, Anatoly

asked 25 Feb '16, 05:27

viktorK's gravatar image

accept rate: 0%

edited 25 Feb '16, 05:28

I don't think there is a api to set the cursor position (Formspider Team correct me if I'm wrong) but it should be possible to do with a little bit of javascript.

I have a working demo of this and if there is enough interest I can put a tar file somewhere, but I'll put instructions below

Create a new application with the following xml in the mainPanel

  <tableLayout cellSpacing="5">
        <textLabel label="Field A"/>
        <textField name="curtest"/>

create a .js file and paste the following code into it

function setCursor(elemName, pos) {
var elem = document.getElementById(elemName);

if(elem != null) {
    if(elem.createTextRange) {
        var range = elem.createTextRange();
        range.move('character', pos);
    else {
        if(elem.selectionStart) {
            elem.setSelectionRange(pos, pos);

I've put mine in the "js" subdirectory and called it cursorTest.js next edit the main.jsp page and add the following line just after it adds the fs-all.js file

<script type="text/javascript" src="js/cursorTest.js?version=1.0"></script>

Next in the formspiderIDE create a new external method with the following settings:-

Name: setCursor
JavaScript Signature: setCursor(string, number)

Leave everything else blank, hit OK

For the demo I've created a simple "init" procedure that is called when the app starts and the code is below

procedure init as
  v_params_t      api_externalMethod.tt_params;

  api_component.setvalue('mainPanel.curtest','this is a test');

  v_params_t('0').value_tx := 'curtest-mainPanel';
  v_params_t('1').value_tx := 0;
  api_externalMethod.invoke('setCursor', v_params_t);
end init;

When you now run the application the cursor should be positioned at the start of the field. hope this helps Simon


answered 27 Feb '16, 05:09

apacheuk's gravatar image

accept rate: 0%

edited 27 Feb '16, 05:11

thanks for the reply. though your code works only in IE - it gave a right direction for the further investigation

(29 Feb '16, 09:59) viktorK

definately works on the version of firefox included in the Oracle Developer VM, but I have to be honest I didn't check it in any other browsers.... glad it helped though

(29 Feb '16, 10:27) apacheuk
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 25 Feb '16, 05:27

Seen: 2,267 times

Last updated: 29 Feb '16, 10:27

© Copyright Gerger 2017