So I have this code but I tought it was too repetitive, anyone has an idea how I could do that? When a upload a new image, I want a new image box to show up. My solution works, but what if I would like to have 1000 new images? I can't just type one at the time. What could I do to optimise this problem?
HTML:
<div class="wrapper">
<div class="box box_image" id="box_image_1">
<div class="js--image-preview"></div>
<div class="upload-options">
<label>
<input type="file" class="image-upload" id="image1" data-show='box_image_2' name="IgniteFormObject.Image1" accept="image/*" enctype="multipart/form-data" />
</label>
</div>
</div>
<div class="box box_image" id="box_image_2">
<div class="js--image-preview"></div>
<div class="upload-options">
<label>
<input type="file" class="image-upload" id="image2" data-show='box_image_3' name="IgniteFormObject.Image2" accept="image/*" enctype="multipart/form-data" />
</label>
</div>
</div>
<div class="box box_image" id="box_image_3">
<div class="js--image-preview"></div>
<div class="upload-options">
<label>
<input type="file" class="image-upload" id="image3" data-show='box_image_4' name="IgniteFormObject.Image3" accept="image/*" enctype="multipart/form-data" />
</label>
</div>
</div>
<div class="box box_image" id="box_image_4">
<div class="js--image-preview"></div>
<div class="upload-options">
<label>
<input type="file" class="image-upload" id="image4" data-show='box_image_5' name="IgniteFormObject.Image4" accept="image/*" enctype="multipart/form-data" />
</label>
</div>
</div>
<div class="box box_image" id="box_image_5">
<div class="js--image-preview"></div>
<div class="upload-options">
<label>
<input type="file" class="image-upload" id="image5" name="IgniteFormObject.Image5" accept="image/*" enctype="multipart/form-data" />
</label>
</div>
</div>
</div>
Javascript:
When an image is uploaded, this JQuery is called.
$('#image1').change(function (ev) {
$("#box_image_2").show();
});
$('#image2').change(function (ev) {
$("#box_image_3").show();
});
$('#image3').change(function (ev) {
$("#box_image_4").show();
});
$('#image4').change(function (ev) {
$("#box_image_5").show();
});