Button to fill in the current date into a date/datetime field

0 views
Skip to first unread message

Patrick Nagel

unread,
Apr 15, 2009, 1:49:29 AM4/15/09
to Semantic Forms
Hi,

it would be good to have a button next to a date/datetime field that inserts
the current date into the field (via JavaScript). Example: in our Wiki we have
a "Task end date", which should only be filled in after the task ended (so
default value that's set from the beginning is not a solution).
Most of the time people will fill in that information on the same day that the
task actually ends, and then it would be very convenient to just click a button.

Maybe it's not a feature that needs to be in Semantic Forms (although I could
imagine a new parameter that causes a button to be placed next to the date /
datetime input fields).
Can anyone think of another way I could get a button into that form?

I figured out that the HTML/JavaScript would have to look like this:

<input type="button" value="Fill in current date" name="fill_in_enddate"
onClick="mydate=new Date();
document.createbox.input_12_day.value=mydate.getDate()">

- but how could I put this into the form, without making my own new extension,
which I currently consider overkill?

Patrick.

--
Key ID: 0x86E346D4 http://patrick-nagel.net/key.asc
Fingerprint: 7745 E1BE FA8B FBAD 76AB 2BFC C981 E686 86E3 46D4

Patrick Nagel

unread,
Apr 17, 2009, 2:48:54 AM4/17/09
to semanti...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Answering my own post...

On 2009-04-15 13:49, Patrick Nagel wrote:
> Can anyone think of another way I could get a button into that form?
>
> I figured out that the HTML/JavaScript would have to look like this:
>
> <input type="button" value="Fill in current date" name="fill_in_enddate"
> onClick="mydate=new Date();
> document.createbox.input_12_day.value=mydate.getDate()">
>
> - but how could I put this into the form, without making my own new extension,
> which I currently consider overkill?

I found the HTMLets extension [1]. Now a file on the Wiki server called
'fill_in_current_date_button.html' contains the code for the button and the
form (at the position where the button should appear) contains
'<htmlet>fill_in_current_date_button</htmlet>'.

Patrick.

[1]: http://www.mediawiki.org/wiki/Extension:HTMLets

- --


Key ID: 0x86E346D4 http://patrick-nagel.net/key.asc
Fingerprint: 7745 E1BE FA8B FBAD 76AB 2BFC C981 E686 86E3 46D4

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknoJlUACgkQyYHmhobjRtTjYACgrXnvmF+tS53MAWTELsJTI/4y
lUgAoLaPvdtRLOfdNnU2F9T6hecYUJKE
=C8WU
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages