-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.cfm
42 lines (39 loc) · 1.78 KB
/
index.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
<script type="text/javascript" src="jquery-2.1.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var max_fields = 25; //maximum input boxes allowed
var wrapper = $(".input_fields_wrap"); //Fields wrapper
var add_button = $(".add_field_button"); //Add button ID
$(".total").html('<input type="hidden" name="total" value="1">');
var x = 1; //initlal text box count
$(add_button).click(function(e){ //on add input button click
e.preventDefault();
if(x < max_fields){ //max input box allowed
x++; //text box increment
$(wrapper).append('<div><div class="pure-control-group"><label for="ip">IP</label><input type="text" name="ip'+x+'"/><a href="#" class="remove_field">Remove</a></div></div>');
$(".total").html('<input type="hidden" name="total" value="'+x+'">');
}
});
$(wrapper).on("click",".remove_field", function(e){ //user click on remove text
e.preventDefault(); $(this).parent('div').remove(); x--;
$(".total").html('<input type="hidden" name="total" value="'+x+'">');
})
});
</script>
<br>
<br>
<br>
<cfform class="pure-form pure-form-aligned" action="iplist.cfm" method="post">
<div class="input_fields_wrap">
<div class="pure-control-group">
<label for="ip">IP</label>
<input type="text" placeholder="50.59.14.1" name="ip1">
</div>
</div>
<div class="total"></div>
<div class="pure-controls">
<button type="submit" class="pure-button pure-button-primary">Submit</button>
<button class="add_field_button pure-button pure-button-primary">Add Field</button>
</div>
</cfform>