Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7523077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:41:30+00:00 2026-05-30T02:41:30+00:00

Here is the form that is inside index.php — I’m trying to programmatically submit

  • 0

Here is the form that is inside index.php — I’m trying to programmatically submit it using a click on an image that’s nested inside an ‘a’ anchor:

  <form name="landingForm" id="landingFormId" method="post" action="index.php">
      <input type="text" size="250" maxlength="250" 
                      id="artifactName">Enter an artifact name here...
      </input>
      <a href="javascript:document.landingForm.submit()">    
          <img src="http://localhost/myProj/bronzeAgeCaveDrawing.jpg" 
                      alt="Submit this form" name="imageFormSubmitter" />
      </a>
  </form>

Here is my php code:

<?php
    if(isset( $_POST['imageFormSubmitter']))
    {
       // this fx just echos a javascript 'alert()'
       showAlertBox("The index page form 'landingForm' was just submitted.");
    }
    else
    {
       var_dump($_GET);
       var_dump($_POST);
    }
  ?>

When I type something in the edit box on the form, then click on the image ‘bronzeAgeCaveDrawing.jpg’ the dump of the GET and POST arrays says:

  array
      Empty

  array
      Empty

And for that matter I’m not even sure the above PHP code is getting called for the

      <a href="javascript:document.landingForm.submit()">

case at all because the above php code executes regardless of whether the form submits — the GET and POST
dumps occur when index.php loads due to the ‘else’ clause above that I added because it didn’t appear that the ‘if’ clause was happening.

If the above php code IS in fact executing by the submit() call, the GET and POST are still empty arrays.

I studied examples of using an anchor ‘a’ with an image combined with a call to submit() in a few posts on SO and I don’t see any reason why the POST or GET array is empty. And due to my form method=”post” I’m 100% expecting for the submit() to POST the form, not submit with a GET.

Been staring at this awhile — am I missing something?

UPDATE: Here is the functioning code — thanks for your help folks!

    <form name="landingForm" id="landingFormId" method="post" action="index.php">
      <input type="text" size="250" maxlength="250"  name="itemName_name"
                      id="artifactName">Enter an artifact name here...
      </input> 
      <a href="javascript: document.landingForm.submit()">    
          <img src="http://localhost/myProj/bronzeAgeCaveDrawing.jpg" 
                 alt="Submit this form" name="imageFormSubmitter" />
      </a>
    </form>


   if(isset( $_POST['itemName_name']))
   {
         showAlertBox("The index page form 'landingForm' was just submitted.");
         var_dump($_POST);
   }

Output of the dump of POST array NOW shows:

   array
       'itemName_name' => string 'fffffffffff' (length=11)

TAKEAWAYS:

1) the syntax "document.landingForm.submit()" is 100% fine.
2) the 'name' attribute of my <img> tag does NOT get posted (not sure why,
      but it's not the worst thing happening for me right now so I'll deal with it)
3) giving the text <input> field a 'name' attribute made its way fine to the POST array.
4) the call to submit() does in fact pay attention to the method="post" in my 
   form declaration.

I’m running with it, thanks all. There is more than one equally acceptable answer for me, so I’ll +1 y’all
then have to choose one. Thanks again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:41:31+00:00Added an answer on May 30, 2026 at 2:41 am

    You’re not setting the name attribute on your <input> tag, and the <img> tag is not the right way to submit with an image.

    <form name="landingForm" id="landingFormId" method="post" action="index.php">
      <input type="text" size="250" maxlength="250" name="artifactName"
                      id="artifactName" />Enter an artifact name here...
      <input type="image" src="http://localhost/myProj/bronzeAgeCaveDrawing.jpg" 
                      alt="Submit this form" name="imageFormSubmitter" />
    </form>
    

    Source: HTML Dog tag reference

    Note also that the <input> tag in HTML5 does not / cannot have children.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a simple form I am using to send XML data in admin_xml.php
I'm trying to load a page that is basically an edit form inside a
I'm trying to to make a form that will submit a new record and
.NET newbie here... I'd like to make a button in a Windows form that
Here is something that I find disturbing. I created a small form, and I'm
I know that can co-exists with web form no problem as Hanselman mention here
To give more information I am using the modular form here: http://jqueryui.com/demos/dialog/#modal-form `b(e.target).zIndex` is
Here is a code form a PHP+MySQL book I am reading and I am
I've been trying to implement the jquery validator that is the suggested answer here:
The following script enables/disables their nested form controls using a for:x class name. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.