PDA

View Full Version : this pointer



frankm
01-24-2006, 09:58 AM
Hi I would like to use to call a function that changes the text in any given text edit to uppercase by using a this pointer. How can I acvcomplish this in Java Script?

Iiro
01-24-2006, 03:34 PM
<span onmouseover="this.style.text-transform='uppercase'">Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. Blah, Blah. </span>

Twey
01-24-2006, 06:59 PM
Hi I would like to use to call a function that changes the text in any given text edit to uppercase by using a this pointer. How can I accomplish this in Java Script?I assume you've accomplished this already in some other language?
Firstly, as with Java, pointers are more-or-less transparent. Secondly, I see no real reason you'd want to use the this keyword here - although, of course, it would depend on how you intend to use this function. onfocus, for example:
<script type="text/javascript">
function elementToUpper(el) {
el.style.text-transform = "uppercase";
}
</script>
<input type="text" onfocus="elementToUpper(this);" value="someText" />