Problem to find the Position of the cursor by using Java Script for an input TextField

Hello

I have a problem to find the position of the cursor in a field inputText component.

The following code of java script to achieve. The same functionality works fine if I run in a simple html page. But when it is used the same javascript inside the jsff does not the position of the cursor.
var adfComponent = AdfPage.PAGE.findComponentByAbsoluteId("r1:1:it3");
var adfComponentClientId = adfComponent.getClientId();
var div = document.getElementById(adfComponentClientId + '::content');
div.focus();
var docSelectionRange = document.selection.createRange();

docSelectionRange.moveStart ('character', -div.value.length);

var iCaretPos = docSelectionRange.text.length;

alert("iCaretPos --> "+iCaretPos);  ---> This statement always returning '0'. Instead, i want the cursor position inside the text box.
Please let me know what I'm missing.

For your reference, sending the sample page html that works fine with the same kind of code.
<html>
 
 <body style="font-family: tahoma; font-size: 8pt;">
 
  <script language="JavaScript">
 
   /*
   **  Returns the caret (cursor) position of the specified text field.
   **  Return value range is 0-oField.length.
   */
   function doGetCaretPosition (oField) {
 
     var iCaretPos = 0;
          alert(oField);
     if (document.selection) { 
 
       // Set focus on the element
       oField.focus ();
 
       // To get cursor position, get empty selection range
       var oSel = document.selection.createRange ();
 
       // Move selection start to 0 position
       oSel.moveStart ('character', -oField.value.length);
 
       // The caret position is selection length
       iCaretPos = oSel.text.length;
     }
 
     // Firefox support
     else if (oField.selectionStart || oField.selectionStart == '0')
       iCaretPos = oField.selectionStart;
 
     // Return results
     return (iCaretPos);
   } 
  
 
 
  </script>
 
  <form name="blah">
 
   Text Field: <input type="text" name="nameEdit" value="">
   <input type="button" value="Get Caret" onClick="document.getElementById('where').value=doGetCaretPosition (document.forms[0].elements[0]);">
<input id="where">
  
 
  </form>
 
 </body>
 
</html>
Thank you and best regards,
Kiran kristelle

Published by: Kiran kristelle on February 6, 2012 12:00

... had the chance to look at the source code of the sample. ADF Faces renders text as HTMLTextArea fields when the value of the rows property. The JavaScript code used in the example of client works differently for FF and IE if the input is a text box. This could be a problem in IE or just used JavaScript code. The rows back to a single line (remove) property makes the text as HTML input feldworking with the JavaScript for IE and FF.

Frank

Tags: Java

Similar Questions

  • Change the value of the radio button using Java Script

    Hi I have a radio button "Process_mode" with two 'ONLINE' and 'Offline' values.
    based on the selection criteria, I will call the process_mode() function and if the user presses the ok button I want to change the proces_mode offline.
    Here's my java script.
    but it does not change the value of the variable.
    Please suggest how to proceed.

    function process_mode()
    {
    confirm_msg = confirm ("your search criteria is complex.") It is proposed to submit the application in offline mode. do you want offline? ») ;
    If (confirm_msg is true)
    {
    $x('p2_process_mode').value = "out of the CONNECTION";
    $x('P2_HIDDEN_PROCESS_MODE').value = "offline";
    }
    }
    doSubmit ('BTN_FINAL_COUNT');
    Alert ("your application has been submitted. Please wait until the system processes your request.') ;

    Thanks and greetings

    Ashok Salimath

    Published by: user644340 on July 19, 2009 23:11

    Hey Ashok,

    A Radio element generates actually individual boxes within a radiogroup (this is done by giving the same "name" attribute to each key). Each button has its own attribute 'ID', which will be the name of the option page more "_n" - where n is a number from 0 (zero) - so the first button will be, say, "P1_RADIO_0", then the second will be "P1_RADIO_1" and so on.

    To set the value of the radiogroup and, therefore, article, you need to 'check' one of the buttons - this is done by setting its 'checked' true value. For example, if "Offline" is the second radio button to the P2_PROCESS_MODE element:

    $x('P2_PROCESS_MODE_1').checked = true;
    

    Andy

  • Problem with finding the SmartGlass an Xbox to Store or App Store

    Original title: xbox a smartglass

    I can't find that the smartglass an Xbox on the windows store or the appstore please help

    Hi Ibrahim.

    Please contact Microsoft Community. I understand that you have a problem with finding the SmartGlass an Xbox to Store or App Store. I will surely you help with this.

    You can download Xbox a SmartGlass from the following Windows store link.

    http://apps.Microsoft.com/Windows/en-us/app/Xbox-one-SmartGlass/c3a46cb8-e733-4579-B716-862e123fa831

    For more information you can check the link.

    http://support.Xbox.com/en-us/Xbox-360/apps/SmartGlass-Info

    Hope this information helps. If you need more assistance or information on this question, reply to this message. I'll be happy to help you.

  • the cursor is jerky and plans for 2004 flight simulator do not run smooth. This only happens when you run games. Is there a solution?

    The cursor is jerky and plans for 2004 flight simulator do not run smooth. This only happens when you run games. Is there a solution?

    Hello

    · What is the number and model of the mouse?

    · Will there be any changes made on the computer before the show?

    You can follow the steps listed in the link below: how to solve the pointer display problems mouse in Microsoft games: http://support.microsoft.com/kb/309703

  • Try to find the terms of use of documents and Web pages

    Hi am writing my

    my university thesis. I'll try to find the terms of use on the use of VMware

    diagrams, documentation and Web page in thesis.  Heart of my thesis is

    the best possible instructions how to install and use Labmanager in

    University teaching. No idea how I read, call, or mail?

    I think that you can reuse for educational purposes.  Just follow the correct citation format (APA, MLA, etc.) for the way in which the thesis is written.

    And I see no reason why you can't, as much as it is for the promotion and support of our product.

    Kind regards

    EvilOne

    VMware vExpert 2009

    NOTE: If your question or problem has been resolved, please mark this thread as answered and awarded points accordingly.

  • How to find the security protocol used by a site in firefox to version 24.6.0

    I'm unable to find the security protocol used by the site, either SSL or TLS 1.0 or 1.2.

    I see my answer above is marked as useless, so I guess it doesn't help for Firefox 24.

    You should be able to see which version of the TLS Protocol and encryption to agree to the current use of press.
    You can use the above posted extension or check in the Security tab of the Web Console (Firefox/tools > Web Developer).
    24 Firefox supports only TLS 1.0 (security.tls.version.max = 1), so that only leaves you with Protocol to guess.

    In Firefox 24 you have the Security tab in "tools > Page Info > Security" to see what level of encryption is used, and you do not see what costume of encryption is used.
    To find you would have to disable any combination of encryption algorithm by setting the Pref security.ssls false and allow both until you get a secure connection.

  • where can I find the price of a product key for windows vista professional?

    where can I find the price of a product key for windows vista professional?

    Unfortunately, the editions of Windows Vista are no longer available for sale.  You can buy Windows 7 from the Microsoft Store. Download and run the Windows 7 Upgrade Advisor and follow the recommendations contained in the report that it generates.

  • Where can I find the Canon EOS 70 d app for my surface?

    Original title: EOS 70 d app

    Where can I find the Canon EOS 70 d app for my surface?

    Hi Roland,

    1. you try to download an app for camera Canon from Store?

    2. using Surface RT or Pro?

    If you looking for an application for camera Canon from Store, you need to find Windows Store or need to contact Canon support check the same.

    For more information, see the article:

    For Surface Pro: install and uninstall applications and programs

    For Surface RT: install and uninstall applications

    If you try to install a software for the Canon camera, then you can view Canon support article.

    Hope the helps of information. Let us know if you need help with Windows related issues. We will be happy to help you.

  • Where can I find the "Extended Support Release" Flash Player for Windows with my creative cloud account?

    Where can I find the "Extended Support Release" Flash Player for Windows after March 1?

    through my creative cloud is account possible?

    now, we are to "Adobe Flash Player Distribution|" "Adobe"

    Hi Mansur_Farooq,

    You can download Adobe Flash Player here: Adobe Flash Player install for all versions

    Let us know if you need additional assistance.

    Kind regards

    Meenakshi

  • My creative cloud subscription ran out. I've updated my contact information. Adobe is deducted from the money, but I can't find the serial number in my account for the product so can't get all running programs. I have the small card, but there letters and

    My creative cloud subscription ran out. I've updated my contact information. Adobe is deducted from the money, but I can't find the serial number in my account for the product so can't get all running programs. I have the small card, but there are letters and numbers. Adobe doesn't let me put those in the fields of serial number. Is it possible I can get Adobe to help me because I'm paying for something that I can't use.

    Hello

    Please check the help below document:

    Quickly find your serial number

    In the case of the volume license product, please visit: site Web of Adobe License | Serial numbers | Orders | Accounts

    Kind regards

    Sheena

  • Find the English version of CS5 download for my mac?  I had to put a new HD.

    Find the English version of CS5 download for my mac?  I had to put a new HD.

    You can download the demo version of the software through the page linked below and then use your current serial number to activate it.

    Don't forget to follow the steps described in the Note: very important Instructions in the section on the pages of this site download and have cookies turned on in your browser, otherwise the download will not work correctly.

    CS5: http://prodesigntools.com/all-adobe-cs5-direct-download-links.html

  • When I create a rectangle, I can not not change the shape of a rectangle with the cursor in illustrator CC 2014 for what?

    When I create a rectangle, I can not not change the shape of a rectangle with the cursor in illustrator CC 2014 for what?

    Xavigarcia,

    I'm afraid that have met you the Rectangle Live bug that is limited to the MAC versions from 10.7 and 10.8, but not of 10.9 (Mavericks) or 10.10 (Yosemite). If all goes well, the bug will be fixed soon.

    Thus, a switch for the Mavericks or Yosemite with a reinstall might be the way to solve it here and now.

    To get around it, in each case, it is possible to develop direct Rectangles to get the normal old shaped rectangles or Pathfinder > unit, or use the scale tool or the free transform tool.

    A more permanent way round that is to create normal old shaped rectangles, after running the free script created by Pawel, see this thread with download link:

    https://forums.Adobe.com/thread/1587587

  • get the id of the component using Java Script

    I have three text fields that I am trying to reset it using Java Script in the Joint Strike Fighter. When, in short, all the text fields three triggered event calls the method below and not reset the other two fields to the point.

    I need to know what text field is under discussion, so I can reset the other two.

    The question that I have does not have the correct id name using evt.getSource ();. I get a big long text for txtField, that looks like: AdfRichInputText [oracle.adf.RichInputText] id = it2

    I'm trying to get just "it2", how do I do this?

    < af:resource type = "javascript" >

    function resetFields (evt) {}

    var txtField = evt.getSource ();

    Alert (txtField);

    If (txtField == 'it2') {}

    var var1 = AdfPage.PAGE.findComponentByAbsoluteId ('it1');

    var var3 = AdfPage.PAGE.findComponentByAbsoluteId ('it3');

    var1. SetValue("");

    var3. SetValue("");

    }

    }

    < / af:resource >

    Thank you very much.

    It worked:

    var txtField = evt.getSource ();

    ID var = txtField.getProperty ("id");     -Returns the name of id for the event source.

  • Java script for counting the text boxes

    I have 10 text boxes. Y at - it somehow I can create a java script for an eleventh text box so whenever you type a number into one of the 10 text boxes it adds the value 1. By example, if you typed a number to 4 number 4 text boxes come in box 11. I googled everywhere and I just can't understand the sense. Any help would be appreciated.

    Of course, it is possible. Let's say the text fields are called "Text1" to "Text10" and the last of them is called "Text11"

    Use this code as the custom Text11 computer code:

    var total = 0;
    for (var i=1; i<=10; i++) {
        if (this.getField("Text"+i).valueAsString!="") total++;
    }
    event.value = total;
    
  • How and where to use Java script to create a new button in the page of detail of the object

    Hi all

    I want to create "New/Add button" in the page of detail of the object. If I'm not mistaken I need to use the java script for this, but could you please let me know how and where to use Java script to create a new button in the page of detail of the CRMOD object.

    Thanks in advance.

    Kind regards
    Manish

    Any related object on the details of the page should have an 'Add' or 'New' or the two default buttons - it of a vanilla feature and will do the required action.

    If you want to change this behavior and do something delicate you will potentially have to to go for javascript. You must add the javascript code in a web custom tab on this object.

    Admin--> Application Customization--> Contact--> Applet Web Contact

    Now add your javascript in the code box, after selecting the type = HTML for this web applet, expose this web applet on the Contact details page layout and your javascript will be called every time this page is loaded.

    Check this document online to see how javascript can be integrated into the CRM on demand http://helponmyproject.com/TTOCOD/

    See you soon!
    Royston

Maybe you are looking for