selection in input
/Html JavaSript/selection in input.html
<script type="text/javascript">
function choix(txt, val) {
this.text = txt;
this.value = val;
return true;
}
function selectText() {
var inp = document.getElementById("theInp");
var l_saisie = 3;
var l_choix = 5;
if (inp.createTextRange) {
//IE
var rg=inp.createTextRange();
rg.moveStart("character", l_saisie);
rg.moveEnd("character", 0);
rg.select();
} else {
inp.selectionStart=l_saisie;
inp.selectionEnd=l_choix;
}
}
</script>
<input type="text" name="theInp" id="theInp" value="texte dans l'input"><br>
<button onclick="selectText()">selectText()</button>