Autocomplete inputs make life easier. However, I am working on a project where the customer insists on having ordinary inputs (radio buttons, checkbox groups and drop down selects). I don't want to change sever-side code and plan to write a javascript function to create these form elements on the client side. I think the best approach is to give a plain textbox input a class and transform it with the function to the ultimate input type. But I don't want to reinvent the wheel, so I thought I'd check if this has already been done. Google didn't bring expected results, so I turn to SO, have you seen such function/plugin?
A:
If I'm understanding your question correctly, you want to serve a form with a bunch of text inputs, then transform it on the client to other forms of inputs (checkboxes, etc)? Not sure I really understand the motivation for this (it'd be easier to just serve up a form that matches what the customer wants, I think), but you should be able to do that using replaceWith or the related functions.
It does seem like something's missing from your description here, though - you'll need to edit the server-side to put a class on each input anyway, so why not just change the type there instead?
Mark Bessey
2010-10-22 16:46:11
I think I'll end up writing the function. Your understanding is correct, the motivation is keeping things simple. Suppose you have a handfull of forms where you need to get a user-id, it is easier to have a textbox for it with a `user-id` class and have a single script which queries the users table and returns user-ids and display names as json data. Without this, you will have to parse a select for each form.
Majid
2010-10-22 17:01:02