endlessInputs jQuery plugin demo
A sample use of my endlessInputs jquery plugin author(s): Michael Haren
by xdumaine
HTML
<script src="https://raw.github.com/mharen/jquery-endless-inputs-plugin/master/jquery.endlessInputs.js"></script>
<fieldset>
<legend>Behold! A never ending list!</legend>
<ol class='endless'>
<li class='endlessItem'><input class='endlessItemInput'/></li>
</ol>
<input id="fulllist"/>
<button onClick="getall();">Test</button>
</fieldset>
<br/>
<fieldset>
<legend>ZOMG! A never ending table!</legend>
<table class='endless'>
<thead>
<tr><th>Foo</th><th>Bar</th></tr>
</thead>
<tbody>
<tr class='endlessItem'>
<td>Random Label</td>
<td><input/></td>
<td><select><option></option><option>hi!</option></select></td>
<td><span class='endlessSkip'>Don't clone this text</span></td>
</tr>
</tbody>
</table>
</fieldset>
JavaScript
$(function() {
$('.endless').endlessInputs();
});
function getall() {
var concat = '';
$('.endlessItemInput').each(function() {
concat += $(this).val() + ',';
});
if (concat.length == 1) {
concat = '';
}
if (concat.length > 1 && concat[concat.length - 1] == ',' && concat[concat.length - 2] == ',') {
concat = concat.substring(0, concat.length - 2);
}
document.getElementById("fulllist").value = concat;
}