Barbara Post wrote:
> Hi Manos and the others who replied :-)
> 
> The javascript code should be written only if I have an "error" tag for a
> specific text input field.
> 
> This error tag is produced by form validation. Then there is the classical
> code :
> 
> <!-- if error element -->
>         <error>
>          <xsl:attribute name="name">
>           <xsl:value-of select="../@Id"/>_<xsl:value-of
> select="@Name"/></xsl:attribute>
>          <xsl:attribute name="when">is-null</xsl:attribute>
>          <font color="red">
>           [explicit error message]
>          </font>
>          [and here I'd like to put my javascript but it fails executing]
>         </error>
> 
> you see that the name of the input field is determined "at xslt runtime"...
> and that the whole code above is in a template matching a certain tag, which
> .../@Id and @Name attributes are used... So I cannot use "onLoad" method...
> Any other ideas ?


Sorry Barbara, I don't really get it and have too much in my poor brain 
right now. Um, you can make the content of the function conditional in 
your XSLT; meaning, just produce an empty function or the field name you 
desire. The body just calls the function but what the function does is 
another story.

If you want to make the javascript *independent of the body tag*, just 
attach the function to the event in your javascript code instead:

<script language="javascript">
// this will trigger init when the document is loaded.
window.onload = init;

function init()
{
   document.getElementById('my_text').focus();
}
</script>

hth,

Manos




---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to