try this:
example
html:
<form id="formId">
a: <input name="a" /><br />
b: <input name="b" /><br />
c: <input type="checkbox" name="c" /><br />
d: <select name="d"><option value="d1">d1</option><option value="d2">d2</option></select><br />
e: <input type="radio" value="1" name="e" /><br />
e: <input type="radio" value="2" name="e" /><br />
e: <input type="radio" value="3" name="e" /><br />
f: <input type="checkbox" name="f" /><br />
</form>
js:
var
data = { a: "value for a", b: "value for b", c: false, d:"d2", e: "2", f:true },
form = $('#formId');
$.each(data, function(i, el) {
var
fel = form.find('*[name="' + i + '"]'),
type = "", tag = "";
if (fel.length > 0) {
tag = fel[0].tagName.toLowerCase();
if (tag == "select" || tag == "textarea") { //...
$(fel).val(el);
}
else if (tag == "input") {
type = $(fel[0]).attr("type");
if (type == "text" || type == "password" || type == "hidden") {
fel.val(el);
}
else if (type == "checkbox") {
if (el)
fel.attr("checked", "checked");
}
else if (type == "radio") {
fel.filter('[value="'+el+'"]').attr("checked", "checked");
}
}
}
})