interesting script here, anyone know how they did it?
hey. a while back i was asking if it were possible to have the cursor in a textbox focus onload to a specific position in the text (that is defaulted in the textbox). in this case i wanted to know if i could have it default at the back of the text instead of the front.
__________________
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)
__________________
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<script>
function set(id){
var txt = document.getElementById(id);
var txtValue = txt.value;
txt.focus();
txt.value = txtValue;
txt.focus();
}
</script>
</head>
<body onload="set('txt')">
<input type="text" id="txt" name="txt" value="test">
<input type="button" onclick="set('txt')" value="set caret to end">
</body>
</html>
works in ie and mozilla.
__________________
public string ConjunctionJunction(string words, string phrases, string clauses)
{
return (String)(words + phrases + clauses);
}
<--- Was I Helpfull? Let me know ---<
i don't know what your talking about, in ie and mozilla it works.
set it onload and you don't need onfocus.
__________________
public string ConjunctionJunction(string words, string phrases, string clauses)
{
return (String)(words + phrases + clauses);
}
<--- Was I Helpfull? Let me know ---<
That's what I was talking about: "in ie and mozilla it works", except with onfocus. No big deal, just pointing out that it works only from an external event, so to speak...
__________________
public string ConjunctionJunction(string words, string phrases, string clauses)
{
return (String)(words + phrases + clauses);
}
<--- Was I Helpfull? Let me know ---<
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
Quote:
Originally Posted by rlemon
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<script>
function set(id){
var txt = document.getElementById(id);
var txtValue = txt.value;
txt.focus();
txt.value = txtValue;
txt.focus();
}
</script>
</head>
<body onload="set('txt')">
<input type="text" id="txt" name="txt" value="test">
<input type="button" onclick="set('txt')" value="set caret to end">
</body>
</html>
works in ie and mozilla.
That partially works in Firefox and probably in Moz too. If you set the caret anywhere but the end, the caret will not go to the end when the button is clicked. Tested it in Opera and didn't work at all.
But you can minimize the code further. The important trick there is focusing first before setting the value.
Code:
function set(id){
var txt = document.getElementById(id);
txt.focus();
txt.value = txt.value;
}
yea, thats why I just stay away from setting the caret.
Made a wysiwyg editor, had a ******* of a time to get that working properly. Still isn't perfect, but w/e.
__________________
public string ConjunctionJunction(string words, string phrases, string clauses)
{
return (String)(words + phrases + clauses);
}
<--- Was I Helpfull? Let me know ---<