Skip to content

Instantly share code, notes, and snippets.

@zachowdhury
Created September 6, 2019 12:09
Show Gist options
  • Save zachowdhury/a25a088eff1b1c6c639aa9b76cd9410f to your computer and use it in GitHub Desktop.
Save zachowdhury/a25a088eff1b1c6c639aa9b76cd9410f to your computer and use it in GitHub Desktop.
Add Element on form on the fly add element to form exampple // source https://jsbin.com/tavudek
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="add element to form exampple">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Add Element on form on the fly</title>
</head>
<body>
<button onClick=addElements()>Add item </button>
<button onClick=deleteElements(indexOf(this))>Delete item </button>
<form>
<lable><h1>insert test on the form</h1></lable>
</form>
<span id="elem"></span>
<script id="jsbin-javascript">
var elem=[];
var dome=btoa(Math.random()).slice(0, 15)
const template= `
<fieldset id= ${dome}>
<lable>email:</lable>
<input type="text"></input>
<button onClick=deleteElements()>delete</button>
</fieldset>`;
function addElements(){
//var elem=[];
elem.push( template);
document.getElementById('elem')
.innerHTML=elem;
}
function deleteElements(_id){
elem.splice(_id,1);
document.getElementById('elem')
.innerHTML=elem;
}
function drawElemnt(){
return 0;
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">var elem=[];
var dome=btoa(Math.random()).slice(0, 15)
const template= `
<fieldset id= ${dome}>
<lable>email:</lable>
<input type="text"></input>
<button onClick=deleteElements()>delete</button>
</fieldset>`;
function addElements(){
//var elem=[];
elem.push( template);
document.getElementById('elem')
.innerHTML=elem;
}
function deleteElements(_id){
elem.splice(_id,1);
document.getElementById('elem')
.innerHTML=elem;
}
function drawElemnt(){
return 0;
}
</script></body>
</html>
var elem=[];
var dome=btoa(Math.random()).slice(0, 15)
const template= `
<fieldset id= ${dome}>
<lable>email:</lable>
<input type="text"></input>
<button onClick=deleteElements()>delete</button>
</fieldset>`;
function addElements(){
//var elem=[];
elem.push( template);
document.getElementById('elem')
.innerHTML=elem;
}
function deleteElements(_id){
elem.splice(_id,1);
document.getElementById('elem')
.innerHTML=elem;
}
function drawElemnt(){
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment