I’m planning to build small plugin in jQuery – just want to check your opinion whether jQuery is the tool for the job.
Basically, I would have two textareas, where I would enter strings (comma or new line separated).
e.g:
textarea 1 content: 1,2,3,4
textarea 2 content: a,b,c,d
After pressing submit I would like jQuery to create every possible combination ( 1a,1b,1c,1d,2a,2b etc....) and return that in a->z order.
Q1. Can jQuery detect new line?(without html mark-up)
Q2. Every list will have 100 – 1000 entries. Will jQuery cope with it?
Q3. Do you know any jQuery function which do something like every possible combination or would that be for loop?
Any suggestions much appreciated.
A simple implementation:
Live demo: http://jsfiddle.net/YvgAM/5/
Explanation:
This function accepts three parameters:
',','\n'.First, you get the elements, then you grab their contents (the text) and split that into an array using the supplied delimiter.
Now, you just use two nested for loop to construct an array of values.
Last, you sort that array and cast it into String.