dnguyen
09-11-2002, 08:00 PM
I'm not looking for keyboard shortcuts and my users want to use keyboard to have the current date show up on the form instead of typing it. The problem with this, is that the field my users want to insert a current date is a comment field. And they want to have control when current date is to be inserted. Instead of it been there everytime. I got this code from another webForum but it only works in IE. I would this to work in Netscape and I'm not very familiar with javascript.
Any help would be appreciated.
Thanks,
<HTML>
<HEAD>
<TITLE>Hot Key Demo</TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
var isCtrlKeyPressed = false;
function hotkey(eventname)
{
if(eventname.keyCode == 17)
{
isCtrlKeyPressed = true;
}
if(eventname.keyCode == 68 && isCtrlKeyPressed)
{
adddate();
}
}
function adddate()
{
document.test.comment.value = "<CFOUTPUT>#DATEFORMAT(NOW(), "MMMM D, YYYY")#: </CFOUTPUT>";
document.test.comment.focus();
}
//-->
</SCRIPT>
</HEAD>
<BODY onkeydown='hotkey(event)'>
<form name="test">
<textarea name="comment" cols="50" rows="4"></textarea>
</form>
Use Ctrl + D to insert date
</font>
</BODY>
</HTML>
Any help would be appreciated.
Thanks,
<HTML>
<HEAD>
<TITLE>Hot Key Demo</TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
var isCtrlKeyPressed = false;
function hotkey(eventname)
{
if(eventname.keyCode == 17)
{
isCtrlKeyPressed = true;
}
if(eventname.keyCode == 68 && isCtrlKeyPressed)
{
adddate();
}
}
function adddate()
{
document.test.comment.value = "<CFOUTPUT>#DATEFORMAT(NOW(), "MMMM D, YYYY")#: </CFOUTPUT>";
document.test.comment.focus();
}
//-->
</SCRIPT>
</HEAD>
<BODY onkeydown='hotkey(event)'>
<form name="test">
<textarea name="comment" cols="50" rows="4"></textarea>
</form>
Use Ctrl + D to insert date
</font>
</BODY>
</HTML>