I've got a page called publish.php which allows a user to enter details of each image (name, description, location , etc) they've just uploaded on the previous page, with each image having its own form to enter this information. Not all forms are displayed at once, rather, all the images are displayed as thumbnails at the top of the page, and clicking on an image hides the previous image's form and shows the current image's form, so it's similar to a tabbed layout.
What I want to do is submit all these forms via a single submit button which is isolated from every form and located in a separate area of the publish.php page - if there's any errors, I'd also like to echo them out. My brief research indicates that this is not possible with HTML alone and AJAX will be required.
Here's a distilled version of what the PHP code looks like to display each image and form:
// Display each image
$i = 0;
foreach ($images as $image) {
echo '<img src="imageSrc'.$i.'" />';
$i++;
}
// Further down the page... display each form...
$i = 0;
foreach ($images as $image) {
include 'publishform.php';
$i++;
}
publishform.php looks a bit like this:
<form id="image<?php echo $i; ?>">
<label>Name</label>
<input name="image[<?php echo $i; ?>][Name]" />
<label>Location</label>
<input name="image[<?php echo $i; ?>][Location]" />
<!-- etc, etc, for description, coordinates, camera etc -->
</form>
So basically, each image is linked to each form by the variable $i which increments as necessary until the end of the $images array is reached. In the top right corner of my page, I've placed a submit button which I want to submit all these forms if there's no errors, and if there are, simply echo them out without submitting.
How would I go about accomplishing this?