Created
September 6, 2019 12:09
-
-
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
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
<!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> |
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 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