I am trying to use a gif instead of a regular submit button.

When I make the changes, it screws up my code. I have the form action going to itself and when I click on the gif to submit the values the user enters, nothing happens. When I change the gif back to a regular submit button, it works again. How can I get this working?

this is what works:

<INPUT type="submit" name="new" value="Send ticket">

This is what I want to work:

<INPUT type="image" src="images\submit.gif" name="new" value="Send Ticket">

The form action is set like this:

<FORM method="POST" action="<?php echo $PHP_SELF ?>">

    <INPUT type="image" src="images\submit.gif" name="new" value="Send Ticket" onClick="document.formname.submit()">

    Add onClick="document.formname.submit()" where formname is the name of the form u want submitted and that should do what you want

    HTH

      This is what I changed the code to:

      <INPUT type="image" src="images\submit.gif" name="new" value="Send Ticket" onClick="document.NewTicket.php.submit()">

      I am getting the error document.NewTicket.php is null or not an object. What am I doing wrong?

        I have also tried:

        <INPUT type="image" src="images\submit.gif" name="new" value="Send Ticket" onClick="document.<?php echo $PHP_SELF ?>.submit()">

        And it's still not working...

          Form name doesn't mean the name of the page, rather the form itself.

          <form name="myForm" method="POST" action="<?php echo $PHP_SELF ?>">
          <input type="image" src="images\submit.gif" name="new" value="Send Ticket" onClick="document.myForm.submit()">
          </form>

            give your form the name 'NewTicket....

            <form action="<? print($_SERVER['PHP_SELF']); ?>" method="post" name="NewTicket">

            ..., because that is the object 'document.NewTicket.submit()' submits.

              Ok - I have made the changes and I am no longer getting the error (thank you!) but the page is not doing anything. It just looks like it is refreshing the page.

              This is what is at the top of my page:

              <FORM name=NewTicket method="POST" action="<?php echo $PHP_SELF ?>">

              This is my submit line:

              <INPUT type="image" src="images\submit.gif" name="new" value="Send Ticket" onClick="document.NewTicket.submit()"></form>

              But as soon as I change the input type to "submit", it works.

              If you would like me to give more code, let me know.

              Thanks for your help...

                Try document.NewTicket.submit(true); instead.

                  I've tried that too and that still doesn't work.

                  I have an if statement:

                  $submit = $_REQUEST["new"];
                  if($submit)
                  {
                  //add the data entered by the user into the database
                  }
                  else
                  {
                  //show the form
                  }

                  With the new statement, when I click on the 'new' button, the code seems to keep going to the else portion of the statement. Why wouldn't it go to the if portion?

                    I just added a print statement for the $submit variable before the if statement, the variable contains no value.
                    Again - when I change it back to type="submit", the button does what it's supposed to.

                    Please help...

                      You need to change the if statement to check something else in the form ... if you have a required field check to make sure its been filled out instead of checking $submit .... when u do if ($submit) ur checking to see if the button was clicked and the form was submitted like normal .... with ur image type button that is not the case so you must check some other value ... the other option (not sure if it will work) is to add a submit button but lable it and hide it then with the onclick run a javascript function that "clicks" the button therefore submitting the form and fullfilling the requirements of "if ($submit)" comparison.

                      Hope that gives u at least a direction to go in...

                      HTH

                        I ended up just taking some of the php code out and putting it into it's own file. So that way the html form action can be directed somewhere else rather than to itself. This ended up working.

                        Thanks everyone for you help!

                          there wasn't anything wrong with your if statement except for one thing ...

                          $submit needs to be changed to $POST['submit']. This was implemented in PHP4 as a security fix. The explanation is $submit is not a global variable(only available on the present page) where as $POST['submit'] is global.

                            And also, an image submit sends two variables back: name.x and name.y - which are represented in PHP by $POST['namex'] and $POST['namey'].

                            The onClick handler shouldn't be necessary unless the image is outside the form; <input type="image"> fires a submit event automatically (it was intended for server-side image maps).

                              Write a Reply...