On 2/13/07, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:

The first line of that function is already included in the plugin


I know, that's where I got it from.

but not generating IDs. Sounds like a good idea, I'll investigate that.


Here's something to start you off:

function generateId(element) {
   if(element.id) {
       // Element already has an ID, so just return that
       return element.id;
   } else {
       // Element doesn't have an ID, so give it one

       // Take the element's name and strip out everything that's invalid
       // (only a-z, A-Z, 0-9, " - ", " _ ", " : ", and " . " are allowed
in IDs)
       // TODO: IDs must start with a letter
       // Example: bday[month] -> bdaymonth
       var genId = element.name.replace(/[^a-zA-Z0-9\-_:\.]/g, "");
       element.id = genId;
       return genId;
   }
}

Thanks again for your input, helps a lot!


No problem, dude! Glad I could help.

--
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]
http://aheimlich.freepgs.com
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to