0

I'm not getting the data from the dynamically created input fields even though I followed the directions ... And the submit button is an image type ... Below is the form

       <td class="textSmall" valign="top">
        New Video Image File:
        <input type="text" name="products_video_xl[]">
        <br>
        Video Image Caption:
        <input type="text" name="products_video_xl_caption[]">
        </td>
  </tr>
<tr>
<td>
    <input type="image" border="0" title=" Preview " alt="Preview" src="includes/languages/english/images/buttons/button_update.gif">
    <a href="/shop/admin/editprdt.php?cPath=292&pID=6362">
    <img border="0" title=" Cancel " alt="Cancel" src="includes/languages/english/images/buttons/button_cancel.gif">
    </a> </form>
    </td> </tr>
</table>
hakre
  • 193,403
  • 52
  • 435
  • 836

3 Answers3

1

I think you believe you are submitting the form but actually users are simply clicking a link to arrive at the other page. unless you click a button to submit the form, the $_POST array will not be generated and therefore certainly won't be present for inspection by the page the user lands on.

You might be able to amend it to

<input type="submit" src="your_image.png" ...>

but that will be a submit button with an image as a background rather than a link which happens to be in the middle of your form.

Hektor
  • 1,845
  • 15
  • 19
  • I am clicking the submit image but it doesn't show the dynamically generated data ... – user3267381 Mar 27 '14 at 18:54
  • I'm getting the other $_POST data though – user3267381 Mar 27 '14 at 19:07
  • I don't think you're supposed to use an array as the name of an element. If you mean to submit several elements in an array then you should name several input elements with the same name. Php will put those into an array within the $_POST array, as with check boxes, which are individual elements each sharing the same name - hence submitted as an array with that shared name. – Hektor Mar 27 '14 at 19:11
  • What does the $_POST array contain at the moment? – Hektor Mar 27 '14 at 19:14
  • You have to use an array as the name of an element for dynamically generated fields .. I have done that many times in the past. – user3267381 Mar 27 '14 at 19:19
  • Oops sorry, seems you're right on that. Well the problem isn't the name of your input elements... – Hektor Mar 28 '14 at 18:54
0

Good Idea to use form with table you have to open and close form outside table

<form>
  <table>
     .........table content form fields
  </table>
</form>
  • you have open form outside table but closed form inside table(which is not good practice may cause problem).
  • your hidden fields outside the put them inside

This is following correct format of html:

UPDATED:

<form method="post" action="shop/admin/editprdt.php?cPath=292&pID=6362&f=images&action=update_image" name="update_image">
    <table width="100%" cellspacing="0" cellpadding="0" border="0">
        <tbody>
            <tr>
                <td class="textSmall" valign="top">
                    <input type="hidden" name="products_previous_video_xl[]">
                    <input type="hidden" name="products_previous_video_xl_caption[]">
                    New Video Image File:
                    <input type="text" name="products_video_xl[]">
                    <br>Video Image Caption:
                    <input type="text" name="products_video_xl_caption[]">
                </td>
                <td class="textSmall" valign="top">
                    New Video Image File:
                    <input type="text" name="products_video_xl[]">
                    <br>Video Image Caption:
                    <input type="text" name="products_video_xl_caption[]">
                </td>
            </tr>
            <tr>
                <td>
                    <input type="image" border="0" title=" Preview " alt="Preview" src="includes/languages/english/images/buttons/button_update.gif">
                    src="includes/languages/english/images/buttons/button_cancel.gif">
                    </a>

                </td>
            </tr>
    </table>
</form>
Manwal
  • 23,450
  • 12
  • 63
  • 93
0

I had a similar situation I had to tackle and my solution works great. Here's the link to the SO post that helped me solve everything. You'l have to tweak to fit your needs but you'll see that it works pretty well.

Dynamically Add Customized HTML Form File Input with jQuery

Community
  • 1
  • 1
rws907
  • 787
  • 4
  • 14
  • 25