Click here to Skip to main content
15,886,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<script type="text/javascript">
    function readURL(input) {
        $('.newlink').remove();
        var count = $('#NumberofImages').val();
        if (input.files && input.files[0]) {
            for (var i = 0; i < input.files.length; i++) {
                var reader = new FileReader();
                $('#images').append('<input type="hidden" name="imageids[' + count + ']" value="' + input.files[i].name + '" />');
                $('#images').append('<input type="hidden" name="keep[' + count + ']" value="1"  data-imageid="' + count + '"/>');
                $('#images').append("<a id='link' class='newlink darken' onclick='ImageClick(" + count + ")' href='javascript:void(0);' data-imageid='" + count++ + "'></a>");
                reader.onload = function (e) {
                    var count = $('#NumberofImages').val();
                    $('#link').append("<img id='image' class='img-rounded' src='" + e.target.result + "' data-imageid='" + count + "' width='80' height='80'/>");
                    $('#link').append('<span class="hoverText" data-imageid="' + count + '">Remove</span>');
                    $('#link').attr('id', 'link' + count);
                    $('#NumberofImages').val(++count);
                };
                reader.readAsDataURL(input.files[i]);
            }
            $('#noimage').remove();
        }
    }
    function ImageClick(val) {
        var clicked = 0;
        $('input[data-imageid]').each(function () {
            if ($(this).attr('data-imageid') == val) {
                clicked = $(this).val();
                if (clicked == 1)
                    $(this).val(0);
                else
                    $(this).val(1);
                clicked = $(this).val();
            }
        });
        if (clicked == 0) {
            $('img[data-imageid]').each(function () {
                if ($(this).attr('data-imageid') == val) {
                    $(this).css("opacity", "0.2");
                    $(this).unbind('mouseenter mouseleave');
                }
            });
            $('span[data-imageid]').each(function () {
                if ($(this).attr('data-imageid') == val)
                    $(this).text("Add");
            });
        }
        else {
            $('img[data-imageid]').each(function () {
                if ($(this).attr('data-imageid') == val) {
                    $(this).hover(function () { $(this).css("opacity", "0.4"); },
                        function () { $(this).css("opacity", "1"); });
</script>

                }
            });
            $('span[data-imageid]').each(function () {
                if ($(this).attr('data-imageid') == val)
                    $(this).text("Remove");
            });
        }
    }

and:
<input type="file" id="imgfiles" class="form-control" name="imgfiles" multiple onchange="readURL(this);" />
Posted

1 solution

Arrows can be generated using pure css.
Here are some examples -
CSS Arrows (Up, Down, Left and Right Triangle)[^]
CSS Triangle[^]
 
Share this answer
 
Comments
Member 11919288 1-Sep-15 4:46am    
But how to use an array of images??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900