Sorry, I resolved this on my own. The problem was outside of the scope of the snippet I included; I had bound the method containing that snippet to a button twice, so it fired once with the elements present, and once with them removed.
--Kit On Thu, Aug 21, 2008 at 12:02 PM, Kit La Touche <[EMAIL PROTECTED]> wrote: > First, apologies; I'm a newb to javascript, and have just joined the list. > > My problem is this: I have defined a function which allows one to edit the > fields of a form, as in change the number, names and labels of the text > inputs. It brings up a div using blockUI, and when you click OK, it takes > the nice new labels you've given it, and repopulates the form with them. > The problem is, it only does this sometimes; sometimes it removes all inputs > and labels from the form. > > The relevant code is something like this: > > $(obj).children('.levels').children('input, br, label').remove(); > $('#new-levels-form').children('input').each(function(i){ > var name = $(this).val(); > if (name) { > $(obj).children('.levels').append( > '<label for="'+name > +'">'+name > +': </label><input class="health-level" type="text" maxlength="1" > name="'+name > +'" size="1" readonly />' > ); > } > }); > > > obj is the specific form on the page that I want to update, .levels is a > div within it that contains the labels and inputs.if there's any more > information I can provide, I'd be happy to. > > So, in summary, sometimes the old inputs and labels are removed, then the > new ones added, sometimes they're removed, and nothing's added -- or, > perhaps, they new ones are added, and then they're all removed. I don't > know quite how to tell. > > Thanks, > > --Kit >