I have a form with several fields and one image. The thing is that I want the image to be displayed when uploading the photo. I manage to do it by putting the image inside another form that is autosubmitted when the image is uploaded. It works well.
My problem is that now, I have two separate form (because you can't nest them). One with all data. And one with the image. My html looks like (basically) :
<form>
<input type="text"/>
<input type="text"/>
<input type="text"/>
</form>
<form> <!--Auto submitted-->
<input type="file"/>
</form>
Problem is the second form is below the first form and ideally, I want the image to be between the first and the second input of the first form. My problem is more from a CSS point of view.
I did some workaround by adding a div in the first form and using javascript to reposition the second form in front of the div, using absolute position. It works but it is "crappy"
<form>
<input type="text"/>
<div id="dummyDiv" style="dimension of the second form found with javascript"></div> <!-- After page load, I use javascript to position the second form here -->
<input type="text"/>
<input type="text"/>
</form>
<form>
<input type="file"/>
</form>
But now I am using responsive design and it is becoming a mess. Is there a way to say "this form must always be positioned on this div" ?"
Demo here : Demo