Discussions
Categories
- 197.1K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.7K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 555 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.3K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 466 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
Cursor jumps to end of text when editing item

I am using a Javascript function, toUpperCase() to convert data input in a text field. However, when users would like to change a piece of the data string in the text, the cursor changes one character only before jumping to the end of the text and continuing. This feature causes aggravation to users. How can I keep the cursor in the correct place within the string and still use toUpperCase without the cursor jumping to the end of the string?
Thank you!
Best Answer
-
the best way to test is to remove OnKeyUp="this.value=this.value.toUpperCase();" and then check whether you still have the problem
strange that the problem is there even when you replace OnKeyUp with onChange because the function should not be executed until the change is complete. also replace OnKeyUp with onBlur
share the results
Answers
-
what event triggers the javascript function. is it onChange?
-
OnKeyUp...so each upstroke causes the Javascript to execute and change the letter to uppercase. This is causing the cursor, I'm guessing, to track to the end of the literal.
-
exactly, change it to onChange and see if the behavior changes
let me know if this answers your query in the current thread
-
I changed the event to OnChange but the effect was the same. The cursor is positioned within a word for one character before being repositioned at the end of the word to add any additional text. Very annoying...
-
are you calling toUpperCase from another javascript function which is called onChange event? if yes,then add alert box after and before the toUpperCase function call and see whether it is this call that does the damage.
i am guessing that some other piece of code is doing the mischief
-
No I do not call the onChange event at all. Within a page item definition, under HTML Form Element Attributes, I specifiy OnKeyUp="this.value=this.value.toUpperCase();" That's it. But I will check if other calls, maybe dynamic function or something else may be interfering. Would the toUpperCase cause the cursor to be repositioned?
-
the best way to test is to remove OnKeyUp="this.value=this.value.toUpperCase();" and then check whether you still have the problem
strange that the problem is there even when you replace OnKeyUp with onChange because the function should not be executed until the change is complete. also replace OnKeyUp with onBlur
share the results
-
Thank you! Sorry it took so long to reply to this but OnBlur did the trick! Thanks!