HighDots Forums  

activate key through javascript

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss activate key through javascript in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Simon
 
Posts: n/a

Default activate key through javascript - 02-28-2007 , 03:09 AM






Hi there,

How can i activate, for example, the insertkey, without pressing the key
itself?
Something like: "window.event.keyCode = 45" won't work.

Any ideas?

It should happen onfocus, and "unhappen" "onunfocus"

(I have an inputfield, value is today's date, but when onfocus it should
type over the first characters so that the year wont have to by retyped.
(After adjusting day and month people can leave the field and go to the next
field.)

Thanks,
Simon



Reply With Quote
  #2  
Old   
scripts.contact@gmail.com
 
Posts: n/a

Default Re: activate key through javascript - 03-01-2007 , 12:22 PM






On Feb 28, 3:09 am, "Simon" <simon1... (AT) quicknet (DOT) nl> wrote:
Quote:
Hi there,

How can i activate, for example, the insertkey, without pressing the key
itself?
Something like: "window.event.keyCode = 45" won't work.

Any ideas?

It should happen onfocus, and "unhappen" "onunfocus"

(I have an inputfield, value is today's date, but when onfocus it should
type over the first characters so that the year wont have to by retyped.
(After adjusting day and month people can leave the field and go to the next
field.)

Thanks,
Simon

Use this :
....
....
<input onkeyup="ief()" onfocus="ief()">
....
....
<script>
function ief(){
txtRg=document.selection.createRange();
txtRg.collapse();
txtRg.moveEnd("character",1)
txtRg.select()
}
</script>



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.