forked from shrishail92/App-on-the-Fly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtext.js
executable file
·50 lines (35 loc) · 1.17 KB
/
text.js
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
43
44
45
46
47
48
49
50
$(document).ready(function(){
var counter = 3;
$("#addButton").click(function () {
if(counter>10){
alert("Only 10 textboxes allow");
return false;
}
var newTextBoxDiv = $(document.createElement('div'))
.attr("id", 'TextBoxDiv' + counter);
newTextBoxDiv.addClass( 'form-group' );
newTextBoxDiv.after().html('<label>Field'+ counter +' name : </label>' +
'<input type="text" name="textbox[' + counter + ']" id="textbox' + counter + '" class="form-control" placeholder="field'+counter+' name">');
newTextBoxDiv.appendTo("#TextBoxesGroup");
$("#hidden").val(counter);
//alert($("#hidden").val());
counter++;
});
$("#removeButton").click(function () {
if(counter==3){
alert("No more textbox to remove");
return false;
}
counter--;
$("#hidden").val(counter);
//alert($("#hidden").val());
$("#TextBoxDiv" + counter).remove();
});
$("#getButtonValue").click(function () {
var msg = '';
for(i=1; i<counter; i++){
msg += "\n Textbox #" + i + " : " + $('#textbox' + i).val();
}
alert(msg);
});
});