I have tried your suggestion. I am retrieved data from a <textarea> form element with these values: 1111 2222 3333 1111 4444
My code that I have been testing using Firefox 3 and Firebug 1.0b4 is: var txtarea = $F('txtarea4').split(/[\n\r]+/); var atxtarea = $A(txtarea).sort(); Array.prototype.isUnique = function(value) { var idx = this.indexOf(value); return this.indexOf(value, idx + 1 == -1); }; for (i=0; i<=atxtarea.length; i++) { alert(atxtarea[i]); atxtarea.isUnique(atxtarea[i]); } The 'alert' shows an 'undefined' value at the end of the loop. I am receiving a -1 after the loop. I have tried to setup the test using: [1111,2222,3333,1111,4444].isUnique(1111) and get a 0 in return (assume this is the index value of 1111) and not a -1 as I would expect. Can you provide me some additional assistance?? On Jun 30, 2:25 pm, kangax <[EMAIL PROTECTED]> wrote: > It's not complicated at all. Take a look > athttp://github.com/kangax/protolicious/tree/master/array.extensions.js... > > -- kangax > > On Jun 30, 8:59 am, few1938 <[EMAIL PROTECTED]> wrote: > > > I am trying to detect whenever an array has a duplicate value and then > > produce an alert to the user that a dupe exists with the value of the > > dupe. > > > Reading 'Prototype & Scriptaculous IN ACTION', I have been able to > > begin the coding to obtain the textarea values and sort the resultant > > array. I am having trouble coding the duplicate value detection. > > > Here is my limited code: > > var txtarea = $F('txtarea4').split(/[\n\r]+/); > > var atxtarea = $A(txtarea).sort(); > > > I think I should use the .detect or .any methods. > > > Frank --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---