You could remove the entire list everytime and regenerate it from
javascript.  Is Themes[0].Subject the actual name, or are you trying
to refer to a javascript object in an array with the attribute
'Subject' which contains the name you are looking for?  If it is the
latter, this won't work.  you'll need to create the html in javascript
and append it into the page.

$('<li><input type="hidden" name="' + Themes[0].Subject + '"
value="A"></li>').appendTo($('#ThemesList'));

I'm actually not sure if jQuery handles appending a list item to a
list properly.  Probaby does.

On Feb 11, 1:19 pm, shapper <mdmo...@gmail.com> wrote:
> Hello,
>
> I am adding and removing a items from a list, using JQuery, which is
> rendered has follows:
>
> <ol id="ThemesList">
>   <li">
>     <input type="hidden" name="Themes[0].Subject" value="A" />
>     <input type="hidden" name="Themes[0].Levels" value="L1,L2" />
>     <input type="hidden" name="Themes[0].Description" value="Paper" />
>   </li>
>   <li">
>     <input type="hidden" name="Themes[2].Subject" value="B" />
>     <input type="hidden" name="Themes[2].Levels" value="L1,L5" />
>   </li>
>   <li">
>     <input type="hidden" name="Themes[5].Subject" value="D" />
>     <input type="hidden" name="Themes[5].Levels" value="L2,L4" />
>     <input type="hidden" name="Themes[5].Description" value="Book" />
>   </li>
> </ol>
>
> Every time I add or remove a Theme I need to be sure that the list is
> ordered (name) starting with Themes[0].
>
> So basically I need to loop through each list item in list ThemesList.
> - In first list item all HIDDEN inputs names should start with "Themes
> [0]"
> - In second list item all HIDDEN inputs names should start with "Themes
> [1]"
> ...
>
> So in this example, "Themes[2]. ..." would become "Themes[1]. ..." and
> "Themes[5]. ..." would become "Themes[2]. ..."
>
> Could someone please help me out?
>
> I have no idea how to do this.
>
> Thanks,
> Miguel

Reply via email to