Move to data-driven decision making with my new NPS survey software.

All my readers receive 10% off for life with code: ian

creating a dynamic list in javascript

November 24, 2004

I thought I'd publish this code out to the world in hopes someone else may find it useful. I'm sure there are optimizations that could be made and I'd love to hear them.

This is a piece of code I came up with for our upcoming product HelpSpot which is a PHP driven Help Desk program. One of the key features is the ability to tag requests with what we call "reporting tags". Each request can have tags associated with it. Later these tags can be used to build very flexible reports on where your requests are coming from, what the major issues are, etc.

Since people would probably be adding lots of tags I wanted to come up with a good way of getting the input without either a request back to the server each time they added one or making them use a textbox and giving lots of instructions about how there should only be one per line, etc.

So this is what I came up with. You can find an example here. It creates a nice simple list on the fly. Each list item gets a hidden form field that in PHP will be passed back as an array of list items. Then I can insert them into the database and so on. This should work on IE6 and all Mozilla's cross platform. It's still being tested and worked on. If we make any major revisions I'll post them here.

→ Share your thoughts with me on Twitter
Stay In The Loop

I won't bother you with short posts or off topic musings. You'll also receive my ebook on enterprise sales for bootstrappers for free.