Skip to content

Instantly share code, notes, and snippets.

@slav123
Created June 23, 2013 04:57
Show Gist options
  • Save slav123/5843850 to your computer and use it in GitHub Desktop.
Save slav123/5843850 to your computer and use it in GitHub Desktop.
set form values, from json
$.each(data, function(name, val){
var $el = $('#listify_form [name="'+name+'"]'),
type = $el.attr('type');
switch(type){
case 'checkbox':
$el.attr('checked', 'checked');
break;
case 'radio':
$el.filter('[value="'+val+'"]').attr('checked', 'checked');
break;
default:
$el.val(val);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment