Index: advpoll-form.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advpoll/advpoll-form.js,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 advpoll-form.js
--- advpoll-form.js	9 Sep 2007 10:34:06 -0000	1.1.2.8
+++ advpoll-form.js	8 Dec 2007 17:56:08 -0000
@@ -87,8 +87,15 @@ Drupal.advpoll.nodeFormAutoAttach = func
   
   $('<a class="add-choice" href="#">'+ Drupal.settings.advPoll.addChoice +'</a>').insertAfter("#more-choices").click(function() {
     var numChoices = $("input.choices").length + 1;
-    // Extract the last choice's offset from its id.
-    var newChoiceN = parseInt($("input.choices:last").attr("id").match(/\d+/)) + 1;
+    // Find the next id to use.
+    var highestId = 0;
+    $("input.choices").each(function() {
+      var id = parseInt($(this).attr("id").match(/\d+/));
+      if (id > highestId) {
+        highestId = id;
+      }
+    });
+    var newChoiceN = highestId + 1;
     // If all choices are removed, use a "backup" of the first choice, else clone the first.
     newChoice = ($("input.choices:first").parent().html() ? $("input.choices:first").parent().clone() : newChoice);
     // Replace choice numbers in label, name and id with the new choice number
