Login  Register

RE: Re: Adding unique IDs in xforms with JS

Posted by Stephanie Hall (TT) on Oct 28, 2009; 3:15pm
URL: https://discuss.orbeon.com/Adding-unique-IDs-in-xforms-with-JS-tp277068p277476.html

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')".

-----Original Message-----
From: Alessandro Vernet [mailto:[hidden email]]
Sent: Monday, October 26, 2009 8:53 PM
To: [hidden email]
Subject: [ops-users] Re: Adding unique IDs in xforms with JS

Stephanie,

On Mon, Oct 26, 2009 at 1:22 PM, Stephanie Hall (TT) <[hidden email]> wrote:
>                                                 <div
> id="div_3">...</div>

You can just keep your div as is, and each iteration will automatically have the id you specified followed by a separator, followed by the index of the iteration (starting with 1). The separator is a special character, and I recommend you use XFORMS_SEPARATOR_1. So in JavaScript to access fourth iteration, you'd
write: "div_3" + XFORMS_SEPARATOR_1 + "4".

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