Skip to content

Commit a7b5452

Browse files
committed
Bug Resolved
1 parent 1ffa5ef commit a7b5452

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

07 - Dynamic Form Field/script.js

+9
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,26 @@ var remove_fields = document.getElementById('remove_fields');
44

55
add_more_fields.onclick = function(){
66
var newField = document.createElement('input');
7+
var input_tags = survey_options.getElementsByTagName('input');
78
newField.setAttribute('type', 'text');
89
newField.setAttribute('name', 'survey_options[]');
910
newField.setAttribute('class', 'survey_options');
1011
newField.setAttribute('siz', 50);
1112
newField.setAttribute('placeholder', 'Another Field');
1213
survey_options.appendChild(newField);
14+
if(input_tags.length > 2){
15+
document.getElementById("remove_fields").style.visibility="visible";
16+
17+
}
1318
}
1419

1520
remove_fields.onclick = function(){
1621
var input_tags = survey_options.getElementsByTagName('input');
1722
if(input_tags.length > 2){
1823
survey_options.removeChild(input_tags[(input_tags.length)-1]);
1924
}
25+
else{
26+
document.getElementById("remove_fields").style.visibility="hidden";
27+
28+
}
2029
}

07 - Dynamic Form Field/style.css

+21-1
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,32 @@ input[type="text"]:focus {
5252
}
5353

5454
#add_fields {
55+
background-color: #4CAF50; /* Green */
56+
border: none;
57+
border-radius: 10px;
5558
color: white;
59+
padding: 15px 32px;
60+
text-align: center;
61+
text-decoration: none;
62+
display: inline-block;
63+
font-size: 16px;
64+
5665
}
5766

67+
68+
5869
#remove_fields {
70+
background-color: #ee052c; /* Red */
71+
border: none;
72+
border-radius: 10px;
73+
margin-left: 70px;
5974
color: white;
60-
float: right;
75+
padding: 15px 32px;
76+
text-align: center;
77+
text-decoration: none;
78+
display: inline-block;
79+
font-size: 16px;
80+
6181
}
6282

6383
.controls a {

0 commit comments

Comments
 (0)