Populate.js
Populate form fields from a JSON object.
Install / Use
/learn @dannyvankooten/Populate.jsREADME
populate.js
A simple JavaScript populate( form, data ) function which will populate form fields from a JSON object.
Input types (text, email, select, multiple select, etc) are taken into account but not validated.
Usage
HTML
<form id="my-form">
<input type="text" name="name" />
<input type="email" name="email" />
<input type="text" name="address[addr1]" />
<input type="text" name="address[city]" />
<input type="text" name="address[state]" />
</form>
JavaScript
// your JSON object
// keys have to match input names
var data = {
"email": "john@doe.com",
"name": "John Doe",
"address": {
"addr1": "Street name",
"city": "City name",
"state": "State"
}
}
// your containing element
var formElement = document.getElementById('my-form');
// populate the form with our JSON object
populate(formElement, data);
Install
Load the JavaScript file in your browser directly or install using NPM:
npm install populate.js
License
MIT licensed.
Related Skills
node-connect
353.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
353.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
353.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
