The jQuery JavaScript library offers some quick and dirty solutions to many problems. I was perusing a jQuery email list when I ran across a simple problem that a beginner JavaScript coder like me could solve. I’ll simplify it a little here to focus this article. Basically, the poster wanted to add form fields to a table, but he wanted to increment a field counter in the HTML and in the id and name tags. Just to make it a little more difficult, the field numbers needed to be padded with leading zeros. Adding the table rows is trivial in jQuery and it turns out that leading zeros are pretty easy too. I like the “everything is an object” approach to JavaScript. You can extend even the built-in objects including the String object. Let’s tackle that first. (more…)