forked from swapnilsparsh/30DaysOfJavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
20 lines (18 loc) · 784 Bytes
/
Copy pathscript.js
File metadata and controls
20 lines (18 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var survey_options = document.getElementById('survey_options');
var add_more_fields = document.getElementById('add_fields');
var remove_fields = document.getElementById('remove_fields');
add_more_fields.onclick = function(){
var newField = document.createElement('input');
newField.setAttribute('type', 'text');
newField.setAttribute('name', 'survey_options[]');
newField.setAttribute('class', 'survey_options');
newField.setAttribute('siz', 50);
newField.setAttribute('placeholder', 'Another Field');
survey_options.appendChild(newField);
}
remove_fields.onclick = function(){
var input_tags = survey_options.getElementsByTagName('input');
if(input_tags.length > 2){
survey_options.removeChild(input_tags[(input_tags.length)-1]);
}
}