Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wzulfikar
Last active September 28, 2016 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wzulfikar/2ca096b8b3a99c2ed3b8fcb7163f160f to your computer and use it in GitHub Desktop.
Save wzulfikar/2ca096b8b3a99c2ed3b8fcb7163f160f to your computer and use it in GitHub Desktop.
Populate HTML input values with given object via jQuery
var populateInputValues = function(o) {
$.each(o, function(name, val){
$('input[name="' + name + '"]').val(val);
});
}
// sample usage via laravel blade
<script type="text/javascript">
populateInputValues({!! json_encode(request()->all()) !!});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment