I want to loop through a form containing various fields and replace them with values I have in a JS object.

E.g.

(1)

<form id="theform">
<input type="text" name="field_1" value="" />
<input type="checkbox" name="field_2" value="" />
</form

(2)

object.field_1 = "Dave";
object.field_2 = ""; // empty as not checked, else holds value of checked one

--

The problem is: what about checkboxes and <select> drop downs, and radios??

Is there a script like this around as I'm guessing this could be useful for Ajax to populate input boxes in some situations (depending on the content etc.) so I'm guessing I'm not the only one who needs this?