Entry
How can I increment the text fields value every time the user clicks in it?
How can I simulate onclick with NN3/4 for a text field/text area?
How can I simulate onclick with NN3/4 for a text field/text area?
Mar 14th, 2000 05:50
Martin Honnen,
IE4+ and NN6 support the onclick handler on nearly any HTML element
including INPUT TYPE="text" fields and TEXTAREA elements. Thus with
them you can write
<INPUT TYPE="text" VALUE="0"
ONCLICK="this.value++"
>
to increase the value every time the field is clicked.
With NN3/4 lacking support for onclick for anything but links and
buttons you need to use onfocus calling your code plus this.blur() to
simulate an onclick effect. This is of course only helpful if the user
doesn't want to or shouldn't type into the field and has the additional
disadvantage that code is executed not only on clicking but also on
tabbing into the field. Anyway the above example using onfocus instead
of onclick
<INPUT TYPE="text" VALUE="0"
ONFOCUS="this.value++; this.blur();"
>