Skip to content

Instantly share code, notes, and snippets.

@blackChef
Created October 15, 2019 02:02
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 blackChef/f1dad62ed5efe4ff9a84bf50b39ef564 to your computer and use it in GitHub Desktop.
Save blackChef/f1dad62ed5efe4ff9a84bf50b39ef564 to your computer and use it in GitHub Desktop.
const item = function(id) {
return `
<input type="text" name="${id}"/>
`;
};
const list = function(ids) {
return `
<div>
${ids.map(item)}
</div>
`;
};
const form = function(ids) {
return `
<form action="">
${list(ids)}
<button type="submit">submit</button>
</form>
`;
};
const render = function(ids) {
const target = document.querySelector('#container');
target.innerHTML = form(ids);
};
// <form action="">
// <div>
// <input type="text" name="0"/>
// <input type="text" name="1"/>
// ...
// </div>
// <button>submit</button>
// </form>
const ids = [0,1,2,3,4];
render(ids);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment