EasyUI Forum
November 01, 2025, 02:29:47 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [SOLVED]Selection js in jeasyui  (Read 13267 times)
guruhyes
Newbie
*
Posts: 8


View Profile Email
« on: October 28, 2019, 05:46:51 PM »

Code:
<head>
    <script type="text/javascript">
        function Select (st,en) {
            var input = document.getElementById ("myText");
            if ('selectionStart' in input) {
                input.selectionStart = st;
                input.selectionEnd = en;
                input.focus ();
            }
            else {  // Internet Explorer before version 9
                var inputRange = input.createTextRange ();
                inputRange.moveStart ("character", 1);
                inputRange.collapse ();
                inputRange.moveEnd ("character", 1);
                inputRange.select ();
            }
        }
    </script>
</head>
<body>
    <input type="text" id="myText" value="Some text for testing"/>
    <button onclick="Select (2,4)">click me</button>
</body>
hai,
the code above is working when i use only javascript,
but when i change the text box to jeasyui the selection not working
Code:
<input type="text" id="myText" class="easyui-textbox" value="Some text for testing"/>
any solution?

sorry for bad english
« Last Edit: November 01, 2019, 09:47:22 PM by guruhyes » Logged
jarry
Administrator
Hero Member
*****
Posts: 2300


View Profile Email
« Reply #1 on: October 28, 2019, 08:25:27 PM »

Please call 'setSelectionRange' method to select text on the textbox component.
Code:
$('#t').textbox('setSelectionRange', {start:2,end:4});
var range = $('#t').textbox('getSelectionRange');
console.log(range);
Logged
guruhyes
Newbie
*
Posts: 8


View Profile Email
« Reply #2 on: October 29, 2019, 03:19:10 AM »

Please call 'setSelectionRange' method to select text on the textbox component.
Code:
$('#t').textbox('setSelectionRange', {start:2,end:4});
var range = $('#t').textbox('getSelectionRange');
console.log(range);

hai Jarry,
thx for your reply,

i did what you suggested, but still not working
Code:
<input name="t" id="t" style="width:300px" type="text" class="easyui-textbox">
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="dbu()">test</a>
<script>
function dbu(){
        $('#t').textbox('setSelectionRange', {start:2,end:4});
           var range = $('#t').textbox('getSelectionRange');
           console.log(range);
        }
</script>

console output
Code:
{start: 0, end: 0}
and i read the documentation, and the method setSelectionRange and getSelectionRange didnt exist
Logged
jarry
Administrator
Hero Member
*****
Posts: 2300


View Profile Email
« Reply #3 on: October 29, 2019, 08:11:22 PM »

Please look at this example http://code.reloado.com/uqatas3/edit#preview. It works fine.
Logged
guruhyes
Newbie
*
Posts: 8


View Profile Email
« Reply #4 on: October 30, 2019, 12:35:08 AM »

Please look at this example http://code.reloado.com/uqatas3/edit#preview. It works fine.

my bad jarry,you might misunderstanding.

i edited my code below
https://jsfiddle.net/guruhyes/hy34j1b6/4/
reff from :http://help.dottoro.com/ljtfkhio.php

so i want to select words inside the text box using click button

when i try your code the console output only
Code:
{start: 2, end: 4}
but i want the words inside the text box
« Last Edit: October 30, 2019, 12:36:56 AM by guruhyes » Logged
jarry
Administrator
Hero Member
*****
Posts: 2300


View Profile Email
« Reply #5 on: October 31, 2019, 12:41:16 AM »

Please look at this updated example http://code.reloado.com/uqatas3/2/edit#preview. It works fine.
Logged
guruhyes
Newbie
*
Posts: 8


View Profile Email
« Reply #6 on: November 01, 2019, 09:46:41 PM »

it works,
thx jarry
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!