The problem is that when the script is executed, there's no such element (yet)

Either delay its execution by wrapping with something like dojo.addOnLoad
(prototype should provide a similar helper)
or move the script at the very end of the html file, just before </body>

On Feb 8, 2008 6:08 PM, Baofeng Yu <[EMAIL PROTECTED]> wrote:
> Say I have a layout.tml that contains header, footer, navi menu, and an
> empty <t:body/> section.
>
> Now in start.tml, I do the following:
>
> <t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
> ...
> <div id="1">
> ...
> </div>
> </t:layout>
>
> When user selects a radio button on the start page, I want to change the
> style of div "1". I know this can be done by using a <t:if> component.
>
> But if I do this in javascript with a function to set the style and add
> that script to the <head>...</head> section (in this case, it's in
> layout.tml), what's the correct way to get div "1" here? (Normally, I
> can use document.getElementById("1") and add script to the the
> header.jsp file.)
>
> Thanks.
> Baofeng
>
>
> Chris Lewis wrote:
> > What exactly do you want to do? What you're explaining doesn't really
> > make sense - that is, hard-coding a DOM id in a component that doesn't
> > contain such an id. What is your ultimate goal?
> >
> > chris
> >
> > Baofeng Yu wrote:
> >> Hi all,
> >>
> >> I have a layout component that wraps around a page, say Start.tml.
> >> Suppose there is a <div id="1"> element on Start.tml. In the
> >> Layout.tml header section, I want to have some JavaScript code to
> >> change that element. What is the correct way to get that element? It
> >> seems document.getElementById('1') doesn't work in this case.
> >>
> >> Thanks in advance,
> >> Baofeng
> >>
> >> ---------------------------------------------------------------------
> >> 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]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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

Reply via email to