|
| 1 | +<!DOCTYPE html> |
| 2 | + |
| 3 | +<!-- |
| 4 | + AddRemoveTextbox v1.0 |
| 5 | + https://www.github.com/kloverde/jquery-AddRemoveTextbox |
| 6 | +
|
| 7 | + Copyright (c) 2016 Kurtis LoVerde |
| 8 | + All rights reserved |
| 9 | +
|
| 10 | + Donations: https://paypal.me/KurtisLoVerde/5 |
| 11 | +--> |
| 12 | + |
| 13 | +<html lang="en-US"> |
| 14 | + <head> |
| 15 | + <meta charset="utf-8"/> |
| 16 | + |
| 17 | + <title>AddRemoveTextbox Demo</title> |
| 18 | + |
| 19 | + <link rel="stylesheet" href="css/demo.css"/> |
| 20 | + |
| 21 | + <style type="text/css"> |
| 22 | + h3 { |
| 23 | + margin-top: 35px; |
| 24 | + } |
| 25 | + </style> |
| 26 | + |
| 27 | + <script |
| 28 | + src="https://code.jquery.com/jquery-3.1.0.min.js" |
| 29 | + integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" |
| 30 | + crossorigin="anonymous"></script> |
| 31 | + |
| 32 | + <script type="text/javascript" src="../jquery.addremovetextbox.js"></script> |
| 33 | + |
| 34 | + <script type="text/javascript"> |
| 35 | + $( document ).ready( function() { |
| 36 | + // Example 1 |
| 37 | + |
| 38 | + $( "#txt\\[0\\]" ).addRemoveTextbox( { |
| 39 | + addButtonClass : "addRemoveButton imgAdd", |
| 40 | + addButtonTooltip : "Add", |
| 41 | + removeButtonClass : "addRemoveButton imgRemove", |
| 42 | + removeButtonTooltip : "Remove" |
| 43 | + } ); |
| 44 | + |
| 45 | + // Example 2 |
| 46 | + |
| 47 | + $( "#number3" ).addRemoveTextbox( { |
| 48 | + addButtonClass : "addRemoveButton imgAdd", |
| 49 | + addButtonTooltip : "Add", |
| 50 | + removeButtonClass : "addRemoveButton imgRemove", |
| 51 | + removeButtonTooltip : "Remove" |
| 52 | + } ); |
| 53 | + |
| 54 | + // Example 3 |
| 55 | + |
| 56 | + $( "#color0" ).addRemoveTextbox( { |
| 57 | + addButtonClass : "addRemoveButton imgAdd", |
| 58 | + addButtonTooltip : "Add", |
| 59 | + removeButtonClass : "addRemoveButton imgRemove", |
| 60 | + removeButtonTooltip : "Remove" |
| 61 | + } ); |
| 62 | + |
| 63 | + // Example 4 |
| 64 | + |
| 65 | + $( "#stuff1" ).addRemoveTextbox( { |
| 66 | + addButtonClass : "addRemoveButton imgAdd", |
| 67 | + addButtonTooltip : "Add", |
| 68 | + removeButtonClass : "addRemoveButton imgRemove", |
| 69 | + removeButtonTooltip : "Remove" |
| 70 | + } ); |
| 71 | + |
| 72 | + // Example 5 |
| 73 | + |
| 74 | + $( "#maxFields1" ).addRemoveTextbox( { |
| 75 | + addButtonClass : "addRemoveButton imgAdd", |
| 76 | + removeButtonClass : "addRemoveButton imgRemove", |
| 77 | + maxFields : 3 |
| 78 | + } ); |
| 79 | + } ); |
| 80 | + </script> |
| 81 | + </head> |
| 82 | + |
| 83 | + <body> |
| 84 | + <p> |
| 85 | + Notes: |
| 86 | + |
| 87 | + <ol> |
| 88 | + <li>You must have an Internet connection to use this demo, as jQuery is pulled from the jQuery CDN.</li> |
| 89 | + <li>Depending on your browser's support for specialized input types, you might not see specialized behavior, and might see standard text boxes instead. The ones featured here are known to work in Firefox 48 and Chrome 52.</li> |
| 90 | + </ol> |
| 91 | + </p> |
| 92 | + |
| 93 | + <h3>Example 2 - ID array notation: <input type="text" id="txt[0]"></h3> |
| 94 | + |
| 95 | + <div id="example1"> |
| 96 | + <div class="txtBoxRow"> |
| 97 | + <input type="text" id="txt[0]" name="txt[0]" class="addRemoveBox border1" maxlength="10"/> |
| 98 | + </div> |
| 99 | + </div> |
| 100 | + |
| 101 | + <h3>Example 2 - ID number notation: <input type="number" id="number3"></h3> |
| 102 | + <p>The ID starts on 3, so the next generated ID will be 4</p> |
| 103 | + |
| 104 | + <div id="example2"> |
| 105 | + <div class="txtBoxRow"> |
| 106 | + <input type="number" id="number3" name="number3" class="addRemoveBox border1" min="1" max="7"/> |
| 107 | + </div> |
| 108 | + </div> |
| 109 | + |
| 110 | + <h3>Example 3: <input type="color" id="color0"></h3> |
| 111 | + <p> |
| 112 | + If your browser supports it, you'll see a color picker here instead of a text field. |
| 113 | + AddRemoveTextbox supports this type, too! |
| 114 | + </p> |
| 115 | + |
| 116 | + <div id="example3"> |
| 117 | + <div class="txtBoxRow"> |
| 118 | + <input type="color" id="color0" name="color0" class="addRemoveBox" value="#ff0000"/> |
| 119 | + </div> |
| 120 | + </div> |
| 121 | + |
| 122 | + <h3>Example 4: Pre-existing fields, IDs out of order and with gaps</h3> |
| 123 | + <p> |
| 124 | + In this example, a set of preexisting input fields are registered. You don't need |
| 125 | + to do anything differently to register the set: simply invoke AddRemoveTextbox on |
| 126 | + any ONE input field within the set. It doesn't matter which one you use, nor does |
| 127 | + it matter if the input fields are in chronological order in the page, nor does it |
| 128 | + matter whether the IDs have gaps in their numbering. |
| 129 | + </p> |
| 130 | + |
| 131 | + <div id="example4"> |
| 132 | + <div class="txtBoxRow"> |
| 133 | + <input type="text" id="stuff0" name="lob0" value="Hello"/> |
| 134 | + </div> |
| 135 | + |
| 136 | + <div class="txtBoxRow"> |
| 137 | + <input type="text" id="stuff8" name="lob3" value="Konichiwa"/> |
| 138 | + </div> |
| 139 | + |
| 140 | + <div class="txtBoxRow"> |
| 141 | + <input type="text" id="stuff1" name="lob1" value="Bonjour"/> |
| 142 | + </div> |
| 143 | + |
| 144 | + <div class="txtBoxRow"> |
| 145 | + <input type="text" id="stuff3" name="lob2" value="Hola"/> |
| 146 | + </div> |
| 147 | + </div> |
| 148 | + |
| 149 | + <h3>Example 5: Setting a limit on how many fields can be generated</h3> |
| 150 | + <p> |
| 151 | + This is set to allow 3 fields. You won't be able to add more after that, |
| 152 | + but if you delete one of them, you'll be able to add one again. |
| 153 | + </p> |
| 154 | + |
| 155 | + <div id="example5"> |
| 156 | + <div class="txtBoxRow"> |
| 157 | + <input type="text" id="maxFields1" name="maxFields1"/> |
| 158 | + </div> |
| 159 | + </div> |
| 160 | + |
| 161 | + <h2>Donations</h2> |
| 162 | + <p> |
| 163 | + I hope you found the code behind these examples helpful. Please consider donating to this project to show your |
| 164 | + support. Your support is greatly appreciated, and it motivates me to keep this project alive and to release |
| 165 | + more open source software. |
| 166 | + </p> |
| 167 | + <a href="https://paypal.me/KurtisLoVerde/5" target="new">https://paypal.me/KurtisLoVerde/5</a> |
| 168 | + </body> |
| 169 | +</html> |
0 commit comments