Login  Register

Re: RE: Re: Adding unique IDs in xforms with JS

Posted by Alessandro Vernet on Nov 11, 2009; 11:48pm
URL: https://discuss.orbeon.com/Adding-unique-IDs-in-xforms-with-JS-tp277068p597405.html

Stephanie,

On Wed, Oct 28, 2009 at 7:15 AM, Stephanie Hall (TT)
<[hidden email]> wrote:

> Thanks for the help, Alex.  What about when you don't know what index you're accessing?  So each row will have a button to do something in javascript with its div and that button will need to be created with each repeat.
>
> So on the third repeat, something like
> <xf:repeat>
>        .
>        .
>        .
>        <tr>
>                <div id="div(dot)3"> //so the (dot)3 will automatically be created as the repeater repeats.
>                        {stuff}
>                </div>
>                <button onclick="toggleSection(????)"/>
>        </tr>
> </xf:repeat>
>
> How can I access that "3" to put in my JS toggleSection function?  Using document.getElementById('div'+XFORMS_SEPARATOR_1+index('project-repeat'))) does not work as it does not recognize the "index('project-repeat')".
You can do the following: In the onclick, "this" will point to the
button. So you can pass it to toggleSection: toggleSection(this), and
in that function look for the div before the <button> and find that ID
for that div.

Alex
--
Orbeon Forms - Web forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
My Twitter: http://twitter.com/avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet