Assigning sequence number inside LI on sortable list
I am working on a draggable / sortable activity scheduler and am trying to figure out how to assign sequence numbers to hidden inputs within each <li>. I have two <ul>'s one with the activity choices (#addOns) and one where activities can be dropped and sorted (#myItin). I have found out how to renumber the <li>'s each time they are sorted, but am trying to figure out how to use that value and append it to a hidden form input.
My current script:
- $('#addOns > li').draggable({helper:'clone', opacity: 0.5, connectToSortable:'#myItin'});
$('.dlt').live("click", function(event) {
event.preventDefault();
$(this).parent().remove();
$('#myItin').sortable('refresh');
});
$('#myItin').sortable({
// recounting upon sort
stop: function(event, ui) {
$('li > span.seq').each(function() {
var $this = $(this);
$this.text($this.parent('li').prevAll().length + 1);
});
}
});
Within each <li> I have hidden inputs:
<input type="hidden" name="activity" value="raft01">
I would like to append the sequence number to the name="activity" so that I end up with name="activity1", name="activity2", etc. There are actually two hidden fields per <li> one for activity and one for number of days, so I need to append the sequence value to two separate input names.
Any suggestions from the gurus
Thanks in advance.