Last active
September 28, 2016 08:03
-
-
Save wzulfikar/2ca096b8b3a99c2ed3b8fcb7163f160f to your computer and use it in GitHub Desktop.
Populate HTML input values with given object via jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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