Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12522
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Fancy Date Entry |
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
| References | <2n7gl7pfgu7mni1bj6cvluit67cnve4ge8@4ax.com> <XnsA0113FAEA48Feejj99@194.109.133.133> <65uil7li894s8dt57kqrkt15fm39o079ta@4ax.com> |
| Message-ID | <XnsA0115D389BE37eejj99@194.109.133.133> (permalink) |
| Date | 2012-03-09 08:09 +0000 |
Gene Wirchenko wrote on 09 mrt 2012 in comp.lang.javascript:
> I must have gotten a bit scared after the earlier difficulty I
> had with keyboard events. I had visions of code rather longer. I
> would prefer to use an input control for consistency with the rest of
> my form, but your code looks quite adaptable. Thank you.
You can easily fake an <input> with css borders on a div, span or td.
Use a hidden input for form-submit output.
An alternative with a size-one inputfield
to collect the last keystroke on focus is interesting,
as focus can easily be applied to more than one field:
====================================
<body onload='document.getElementById("i").focus()'>
[<span id=a>20120307</span><span
id=b style='color:red;'></span>]
<input onkeyup='getKey(this)' size=1
style='width:10px;font-size:7pt;' id=i>
<br><br>
re-initialize by pressing 'i'.
<br>
show result with 'r'
<script type='text/javascript'>
var s = '';
function getKey(t) {
var char = t.value;
t.value='';
if (char=='i') s = '';
if (char=='r') return show();
if (char>=0 && char<=9) s += char;
if (s.length<9) {
document.getElementById('a').innerHTML =
'20120307'.substr(0,8-s.length);
document.getElementById('b').innerHTML = s;
};
};
function show() {
alert(document.getElementById('a').innerHTML +
document.getElementById('b').innerHTML);
};
</script>
====================================
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Fancy Date Entry Gene Wirchenko <genew@ocis.net> - 2012-03-07 19:02 -0800
Re: Fancy Date Entry "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-08 23:23 +0000
Re: Fancy Date Entry Gene Wirchenko <genew@ocis.net> - 2012-03-08 19:32 -0800
Re: Fancy Date Entry "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-09 08:09 +0000
Re: Fancy Date Entry Dr J R Stockton <reply1210@merlyn.demon.co.uk> - 2012-03-09 21:18 +0000
csiph-web