cool, just for completeness though:
when upgrading from woody to cforms (which is highly recommended) you should:
watch out with those on_load thingies, you might be killing the necessary onload of other widgets in the form (e.g. used by advanced widgets like calendar or html area and whatnot)
the way to add your own code to the 'onload' event is therefor a bit different when you use the provided xsl's from samples/resources
forms_onloadHandlers[forms_onloadHandlers.length] = document.login.id.focus; // not tested, so might have some syntax issues
see the forms_onloadHandlers Array declared and used in form_lib.js http://cvs.apache.org/viewcvs.cgi/cocoon/trunk/src/blocks/forms/samples/resources/forms-lib.js?rev=36594&root=Apache-SVN&view=auto
HTH -marc=
[EMAIL PROTECTED] wrote:
We found out how to do it yesterday: give the template a name-attribute (e.g. login) and the body tag an onload attribute with value: document.nameOfForm.NameOfField.focus()
Regards, Robby
<html>
<head>
<title>Access Control</title>
</head>
<body onload="document.login.id.focus();">
<h1>Login</h1>
<p>${message}</p>
<wt:form-template
action="continuation:${cocoon.continuation.id}"
method="POST"
name="login">
<table class="panel"> <caption>Login</caption>
<tr> <td> <wi:group> <wi:styling layout="columns"/>
<wi:items> <wt:widget id="id"/>
<wt:widget id="password">
<wi:styling type="password"/>
</wt:widget>
<wt:widget id="changepassword"/>
</wi:items> </wi:group> </td> </tr> </table> <wt:widget id="login">
<wi:styling class="button"/>
</wt:widget>
<wt:widget id="cancel">
<wi:styling class="button"/>
</wt:widget>
</wt:form-template>
</body>
</html>
-----Original Message-----
From: Ulf Sahlin [mailto:[EMAIL PROTECTED]
Sent: 08 September, 2004 09:48
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Woody question (how to give certain field focus at onload
of document)
Hello Robby!
You could try some <fi:styling myAttr="doSomething()"> element in the form template, since all attributes to that element is copied into the resulting input tag in the standard cforms field transformer:
... <xsl:if test="fi:styling"> <xsl:copy-of select="fi:styling/@*"/> </xsl:if> ...
Another option would be to include a simple javascript in the template that does the focusing job.
Regards, Ulf Sahlin
-----Ursprungligt meddelande----- Från: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Skickat: den 7 september 2004 15:46 Till: [EMAIL PROTECTED] Ämne: Woody question (how to give certain field focus at onload of document)
Hi,
anyone who knows how to give a woody field (input field) focus when the page is loaded ?
Kind regards, Robby
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Marc Portier http://outerthought.org/ Outerthought - Open Source, Java & XML Competence Support Center Read my weblog at http://blogs.cocoondev.org/mpo/ [EMAIL PROTECTED] [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]