Click here to Skip to main content
15,902,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have Datalist control with item template as textbox...user enter the values in textboxes then select particular text in any of textbox....how get the selected text in java script
Posted
Updated 4-Oct-12 1:58am
v2

Try this
JavaScript
function isTextSelected(input) {
    if (typeof input.selectionStart == "number") {
        return input.selectionStart == 0 && input.selectionEnd == input.value.length;
    } else if (typeof document.selection != "undefined") {
        input.focus();
        return document.selection.createRange().text == input.value;
    }
}

with this
XML
<input type="text" id="test" value="Some text">
<input type="button" onmousedown="alert(isTextSelected(document.getElementById('test')));" value="Selected?">
 
Share this answer
 
v2
select particular text means what ? can u explain it ?
 
Share this answer
 
Comments
__PP__ 4-Oct-12 7:31am    
Just Selection...like select for cut and paste

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900