Are you talking about using Themes[0] in name?

The page was validated by W3C validator ...

Do you mean something else?

On Feb 11, 10:16 pm, mkmanning <michaell...@gmail.com> wrote:
> At the risk of repeating myself from other posts, You might save
> yourself future problems if you use standards-based id/name attributes
> (and if the framework you're using doesn't allow that, seriously
> consider a different framework):
>
> HTML 4 spec section 6.2 says, "ID and NAME tokens must begin with a
> letter ([A-Za-z]) and may be followed by any number of letters,
> digits
> ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods
> (".")."
>
> XHTML spec section C.8 says, "Note that the collection of legal
> values
> in XML 1.0 Section 2.3, production 5 is much larger than that
> permitted to be used in the ID and NAME types defined in HTML 4. When
> defining fragment identifiers to be backward-compatible, only strings
> matching the pattern [A-Za-z][A-Za-z0-9:_.-]* should be used. See
> Section 6.2 of [HTML4] for more information."
>
> On Feb 11, 2:09 pm, shapper <mdmo...@gmail.com> wrote:
>
> > Themes[0].Subject is the actual name ... It is so to be read by an MVS
> > framework into a List.
>
> > Basically when the page loads some items are already there rendered on
> > the server.
> > They are always with the correct order.
>
> > However, when I add / remove items to that list the order might
> > change ...
>
> > So I should add and remove all items? How can I do this? And why?
>
> > I am posting my entire code:
>
> >     // Cancel button
> >     $('#Cancel').click(function() { location.href = '/Account/
> > List'; });
>
> >     // Themes >>
>
> >       // Remove theme
> >       $('.Remove').livequery('click', function(event) {
> >         $(this).parent().remove();
> >       });
>
> >       // Add theme
> >       $('#AddTheme').bind('click', function(){
>
> >         // Define index
> >         $index = $('#Index');
>
> >         // Set valid
> >         var valid = new Boolean(true);
>
> >         // Define fields
> >         $description = $('#Description');
> >         $levels = $('input[name="Levels"]:checked + label');
> >         $levelsTypes = $('input[name="Levels"]:checked');
> >         $subject = $('#Subject option:selected');
>
> >         // Map levels
> >         levels = $levels.map(function() { return $(this).text(); }).get
> > ();
> >         levelsTypes = $levelsTypes.map(function() { return $(this).val
> > (); }).get();
>
> >         // Validate
> >         if (!$subject.val()) { valid = false; }
> >         if (!levels.length) { valid = false; }
>
> >         // Validate
> >         if (valid) {
>
> >           // Define theme
> >           $theme = $('<li class="Themes"></li>').appendTo
> > ('#ThemesOnTutor');
>
> >           // Add fields
> >           $theme.append($subject.text()).append('<br />');
> >           $theme.append(FriendlyLevels(levels) + '<br />');
> >           if ($description.val()) {$theme.append($description.val
> > ()).append('<br />');}
>
> >           // Add button
> >           $theme.append('<a href="#Remove" class="Remove">Remover</
> > a>');
>
> >           // Add inputs
> >           $theme.append('<input type="hidden" name="Themes.Index"
> > value = "' + $index.val() + '" />');
> >           $theme.append('<input type="hidden" name="Themes[' +
> > $index.val() + '].Subject" value = "' + $subject.val() + '" />');
> >           $theme.append('<input type="hidden" name="Themes[' +
> > $index.val() + '].LevelsCsv" value = "' + levelsTypes.join(",") + '" />');
>
> >           $theme.append('<input type="hidden" name="Themes[' +
> > $index.val() + '].Description" value = "' + $description.val() + '" /
>
> > >');
>
> >           // Increment index
> >           $index.val(+$index.val() + 1);
>
> >         }
>
> >       });
>
> >       // FriendlyLevels
> >       function FriendlyLevels(levels) {
> >         if (levels.length < 2) return levels.join('');
> >         var first = levels.slice(0, -1), last = levels.slice(-1);
> >         var friendly = first.join(', ');
> >         if (last) { friendly += ' e ' + last; }
> >         return friendly;
> >       } // FriendlyLevels
>
> > On Feb 11, 9:47 pm, seasoup <seas...@gmail.com> wrote:
>
> > > 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