Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: f3bd84666f
Fetching contributors…

Cannot retrieve contributors at this time

file 61 lines (53 sloc) 1.789 kb
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 51 52 53 54 55 56 57 58 59 60 61
<html>
<head>
    <style>
    a.remove, a.remove-2 {
        color:#B11E23;
    }
    a#add, a#add-2 {
        color:#1A9919;
        float:left;
    }
    
    </style>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
    <script type="text/javascript" src="jquery.duplicator.js"></script>
    
    <script type="text/javascript" charset="utf-8">
    $(function(){
        
        $('.duplicate-wrap').duplicator({
            addSelector : '#add',
            removeSelector : '.remove',
            removeMarkup : '<a href="#" class="remove">[-]</a>',
            slideEffect : true,
            maxDuplicates : 5,
            limit : function(limit) {
                                 alert('fields are full! you can only have '+limit);
                             }
        });
        
        $('.duplicate-wrap-2').duplicator({
            addSelector : '#add-2',
            removeSelector : '.remove-2',
            removeMarkup : '<a href="#" class="remove-2">[-]</a>'
        });
        
    });
        
    </script>
</head>
<body>
    <form>
        <h3>Tags</h3>
        <a href="#" class="btn" id="add">[+]</a>
        <div class="duplicate-wrap">
            <input type="text" name="tags[]" value="">
        </div>

        <h3>Categories</h3>
        <a href="#" class="btn" id="add-2">[+]</a>
        <div class="duplicate-wrap-2">
            <select name="categories[]">
                <option value="cat_1">Category 1</option>
                <option value="cat_2">Category 2</option>
                <option value="cat_3">Category 3</option>
                <option value="cat_4">Category 4</option>
            </select>
        </div>
    
    </form>
</body>
</html>
Something went wrong with that request. Please try again.