Image button doesn't work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    Image button doesn't work

    I have a image button in php. But it doesn't work. This is my code

    Code:
    <form method="post" action="user.php">
    <input name="Remove" src="../images/Remove.jpg"  type="image" />
    
    if(isset($_POST['Remove'])){
    					
    	echo "remove";
    }	
    
    </form>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    what does not work?

    .....

    Comment

    • ghjk
      Contributor
      • Jan 2008
      • 250

      #3
      When I click remove button I want to
      Code:
      echo "Remove";
      . But nothing append and page refresh only

      Comment

      • zorgi
        Recognized Expert Contributor
        • Mar 2008
        • 431

        #4
        Code:
        <form method="post" action="user.php">
        <input name="Remove" value="remove" src="../images/Remove.jpg"  type="image" />
        <?php
        
        if(isset($_POST['Remove'])){
         
            echo "remove";
        }    
        ?> 
        </form>
        This works... I only added: value="remove" for your button and <?php ?>

        Comment

        • ghjk
          Contributor
          • Jan 2008
          • 250

          #5
          Thnx. But it doesn't work on IE. I'm using IE. Please help me..

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            It won't do anything because you're not submitting the form...

            Code:
            <form id="myform" method="post" action="">
                <input type="image" src="../path/to/img.jpg" name="Remove" onclick="document.getElementById('myform').submit();" />
            
            <?php if (isset($_POST['Remove'])) echo "remove"; ?>
            
            </form>
            Not sure if the javascript's right (dormilich?) - also, not sure it a type=image input acts as a submit button (making the javascript pointless).

            Comment

            • zorgi
              Recognized Expert Contributor
              • Mar 2008
              • 431

              #7
              Oups

              There is this solution to this IE bug without using javascript:

              Code:
              <form method="post" action="">
              
              <button type="submit" name="Remove" style="border: 0; background: transparent; cursor: pointer;">
                  <img src="../images/Remove.jpg"  />
              </button>
              
              <?php
              if(isset($_POST['Remove'])){
                  echo "remove";
              }    
              ?> 
              </form>

              Comment

              • ghjk
                Contributor
                • Jan 2008
                • 250

                #8
                Thnk you all. zorgi 's code is working..

                Comment

                Working...