Input Type image submit form value?












36















I am using this code to try and submit a value via form but it doesn't seem to submit anything...



I would normally use a checkbox or Radio buttons for multiple options but I want to use an image to do this.



Is this code wrong?



<input id="test1" name="test1" type="image" src="images/f.jpg" value="myValue" alt="" />


So I want to pass the value in value="myValue".



The form works fine so that's not the problem, I just need help with the input part not submitting as I know that works.



Thanks










share|improve this question




















  • 1





    This code can't submit a thing. Could you write the whole code for the form?

    – Michael Sazonov
    Oct 28 '11 at 22:19






  • 1





    Your input looks fine. What does the server-side code look like? Also the entire form might be helpful.

    – Brendan Long
    Oct 28 '11 at 22:20






  • 2





    @Michael Sazonov — Yes it can, that is what image inputs do.

    – Quentin
    Oct 28 '11 at 22:25






  • 1





    @Quentin - You're right, my mistake.

    – Michael Sazonov
    Oct 28 '11 at 22:27
















36















I am using this code to try and submit a value via form but it doesn't seem to submit anything...



I would normally use a checkbox or Radio buttons for multiple options but I want to use an image to do this.



Is this code wrong?



<input id="test1" name="test1" type="image" src="images/f.jpg" value="myValue" alt="" />


So I want to pass the value in value="myValue".



The form works fine so that's not the problem, I just need help with the input part not submitting as I know that works.



Thanks










share|improve this question




















  • 1





    This code can't submit a thing. Could you write the whole code for the form?

    – Michael Sazonov
    Oct 28 '11 at 22:19






  • 1





    Your input looks fine. What does the server-side code look like? Also the entire form might be helpful.

    – Brendan Long
    Oct 28 '11 at 22:20






  • 2





    @Michael Sazonov — Yes it can, that is what image inputs do.

    – Quentin
    Oct 28 '11 at 22:25






  • 1





    @Quentin - You're right, my mistake.

    – Michael Sazonov
    Oct 28 '11 at 22:27














36












36








36


8






I am using this code to try and submit a value via form but it doesn't seem to submit anything...



I would normally use a checkbox or Radio buttons for multiple options but I want to use an image to do this.



Is this code wrong?



<input id="test1" name="test1" type="image" src="images/f.jpg" value="myValue" alt="" />


So I want to pass the value in value="myValue".



The form works fine so that's not the problem, I just need help with the input part not submitting as I know that works.



Thanks










share|improve this question
















I am using this code to try and submit a value via form but it doesn't seem to submit anything...



I would normally use a checkbox or Radio buttons for multiple options but I want to use an image to do this.



Is this code wrong?



<input id="test1" name="test1" type="image" src="images/f.jpg" value="myValue" alt="" />


So I want to pass the value in value="myValue".



The form works fine so that's not the problem, I just need help with the input part not submitting as I know that works.



Thanks







html forms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 28 '11 at 22:23







Satch3000

















asked Oct 28 '11 at 22:17









Satch3000Satch3000

15.9k73176308




15.9k73176308








  • 1





    This code can't submit a thing. Could you write the whole code for the form?

    – Michael Sazonov
    Oct 28 '11 at 22:19






  • 1





    Your input looks fine. What does the server-side code look like? Also the entire form might be helpful.

    – Brendan Long
    Oct 28 '11 at 22:20






  • 2





    @Michael Sazonov — Yes it can, that is what image inputs do.

    – Quentin
    Oct 28 '11 at 22:25






  • 1





    @Quentin - You're right, my mistake.

    – Michael Sazonov
    Oct 28 '11 at 22:27














  • 1





    This code can't submit a thing. Could you write the whole code for the form?

    – Michael Sazonov
    Oct 28 '11 at 22:19






  • 1





    Your input looks fine. What does the server-side code look like? Also the entire form might be helpful.

    – Brendan Long
    Oct 28 '11 at 22:20






  • 2





    @Michael Sazonov — Yes it can, that is what image inputs do.

    – Quentin
    Oct 28 '11 at 22:25






  • 1





    @Quentin - You're right, my mistake.

    – Michael Sazonov
    Oct 28 '11 at 22:27








1




1





This code can't submit a thing. Could you write the whole code for the form?

– Michael Sazonov
Oct 28 '11 at 22:19





This code can't submit a thing. Could you write the whole code for the form?

– Michael Sazonov
Oct 28 '11 at 22:19




1




1





Your input looks fine. What does the server-side code look like? Also the entire form might be helpful.

– Brendan Long
Oct 28 '11 at 22:20





Your input looks fine. What does the server-side code look like? Also the entire form might be helpful.

– Brendan Long
Oct 28 '11 at 22:20




2




2





@Michael Sazonov — Yes it can, that is what image inputs do.

– Quentin
Oct 28 '11 at 22:25





@Michael Sazonov — Yes it can, that is what image inputs do.

– Quentin
Oct 28 '11 at 22:25




1




1





@Quentin - You're right, my mistake.

– Michael Sazonov
Oct 28 '11 at 22:27





@Quentin - You're right, my mistake.

– Michael Sazonov
Oct 28 '11 at 22:27












12 Answers
12






active

oldest

votes


















52














An input type="image" only defines that image as the submit button and not as an input that can carry over a value to the server.






share|improve this answer
























  • So, what can I use where I can use an image?

    – Satch3000
    Oct 28 '11 at 22:24











  • Just to clear your question a bit more, are you trying to submit the image itself to the server?

    – Francisco Paulo
    Oct 28 '11 at 22:26











  • No, I have an image as a button (or want to), so if the user clicks this image it adds a value from value="myvalue" and this value will be submitted with the form. So instead of using an input box or a checkbox or other I'm trying to use an image.

    – Satch3000
    Oct 28 '11 at 22:29






  • 12





    Ok. I don't think that the behaviour of browsers regarding the value in an image input is the same across the board. I would use an input="hidden" to keep the value, that way the user would just see the image and you could be sure that the value would be submitted.

    – Francisco Paulo
    Oct 28 '11 at 22:38



















34














Using the type="image" is problematic because the ability to pass a value is disabled for some stupid lack of reason. Anyways & although it's not as customizable & thus as pretty, you can still use you images so long as they are part of a type="button".



<button type="submit" name="someName" value="someValue"><img src="someImage.png" alt="SomeAlternateText"></button>


Hope this helps! ^_^






share|improve this answer



















  • 4





    If you do this I believe you need to add a border="0" else some browsers might add an ugly bordered window

    – Dynelight
    Apr 10 '13 at 14:00






  • 5





    "Some browsers"? I wonder which ones :P

    – Kenton de Jong
    Nov 12 '13 at 20:13



















7














I was in the same place as you, finally I found a neat answer :



<form action="xx/xx" method="POST">
<input type="hidden" name="what you want" value="what you want">
<input type="image" src="xx.xx">
</form>





share|improve this answer































    6














    I've found that image-buttons DO return a response, but you should NOT use a value-option. What I see returned are two version of the name="MYNAME" with .X and .Y endings.



    For example:



    <input type="image" src="/path-to/stop.png" name="STOP" width="25" height="25" align="top" alt="Stop sign">


    This is within your <form> to </form>. If you click the image, what's returned are STOP.X and STOP.Y with numeric values. The existence of either indicates the STOP image-button was clicked. You don't need any special code. Just treat it as another kind of "submit" button that returns a pair of augmented NAMEs.



    I've tried this on Safari, Firefox and Chrome. The image wasn't displayed with Safari, but where it was supposed to be located, my cursor turned into a finger-icon, and I could click it.






    share|improve this answer

































      4














      Some browsers (IIRC it is just some versions of Internet Explorer) only send the co-ordinates of the image map (in name.x and name.y) and ignore the value. This is a bug.



      The workarounds are to either:




      • Have only one submit button and use a hidden input to sent the value

      • Use regular submit buttons instead of image maps

      • Use unique names instead of values and check for the presence of name.x / name.y






      share|improve this answer

































        3














        Here is what I was trying to do and how I did it. I think you wanted to do something similar.
        I had a table with several rows and on each row I had an input with type image. I wanted to pass an id when the user clicked that image button. As you noticed the value in the tag is ignored. Instead I added a hidden input at the top of my table and using javascript I put the correct id there before I post the form.



        <input type="image" onclick="$('#hiddenInput').val(rowId) src="...">


        This way the correct id will be submitted with your form.






        share|improve this answer































          1














          You could use a radio button/checkbox and set it to hide the button in css and then give it a label with an image.



          input[type="radio"] {display: none}
          input[type="radio"] + label span {display: block}


          Then on the page:



          <input type="radio" name="emotion" id="mysubmitradio" />
          <label for="mysubmitradio"><img src="images/f.jpg" />
          <span>if you need it</span></label>


          And then set it to submit using javascript:



          document.forms["myform"].submit();





          share|improve this answer































            1














            Solution:



            <form name="frmSeguimiento" id="frmSeguimiento" method="post" action="proc_seguimiento.php">  
            <input type="hidden" name="accion" id="accion"/>


            <input name="save" type="image" src="imagenes/save.png" alt="Save" onmouseover="this.src='imagenes/save_over.png';" onmouseout="this.src='imagenes/save.png';" value="Save" onclick="validaFrmSeguimiento(this.value);"/>


            function validaFrmSeguimiento(accion)
            {
            document.frmSeguimiento.accion.value=accion;

            }


            Regards,
            jp






            share|improve this answer































              1














              Inputs of type="image" don't send their name/value pair when used to submit the form. To me, that sounds like a bug, but that's how it is.



              To get around this, you can replace the input with a button of type="submit", and put a img element inside.



              Unfortunately, that causes your image to be in a ugly HTML "button". However, assuming you aren't using the standard HTML button anywhere, you can just override the stylesheet, and then everything should work as expected:






              button, input[type="submit"], input[type="reset"] {
              background: none;
              color: inherit;
              border: none;
              padding: 0;
              font: inherit;
              cursor: pointer;
              outline: inherit;
              }

              <form action="/post">
              <input name="test">
              <button type="submit" name="submit_button" value="submitted">
              <img src="https://via.placeholder.com/32" alt="image">
              </button>
              </form>








              share|improve this answer































                0














                well if i was in your place i would do this.I would have an hidden field and based on the input image field i would change the hidden field value(jQuery), and then finally submit the hidden field whose value reflects the image field.






                share|improve this answer































                  -2














                  Add this



                      name="myvalue"


                  To your tag.






                  share|improve this answer































                    -7














                    To submit a form you could use:



                    <input type="submit">


                    or



                    <input type="button"> + Javascript 


                    I never heard of such a crazy guy to try to send a form using a image or a checkbox as you want :))






                    share|improve this answer


























                    • Damn Daniel, hear now

                      – Tilak Maddy
                      May 10 '17 at 16:42











                    Your Answer






                    StackExchange.ifUsing("editor", function () {
                    StackExchange.using("externalEditor", function () {
                    StackExchange.using("snippets", function () {
                    StackExchange.snippets.init();
                    });
                    });
                    }, "code-snippets");

                    StackExchange.ready(function() {
                    var channelOptions = {
                    tags: "".split(" "),
                    id: "1"
                    };
                    initTagRenderer("".split(" "), "".split(" "), channelOptions);

                    StackExchange.using("externalEditor", function() {
                    // Have to fire editor after snippets, if snippets enabled
                    if (StackExchange.settings.snippets.snippetsEnabled) {
                    StackExchange.using("snippets", function() {
                    createEditor();
                    });
                    }
                    else {
                    createEditor();
                    }
                    });

                    function createEditor() {
                    StackExchange.prepareEditor({
                    heartbeatType: 'answer',
                    autoActivateHeartbeat: false,
                    convertImagesToLinks: true,
                    noModals: true,
                    showLowRepImageUploadWarning: true,
                    reputationToPostImages: 10,
                    bindNavPrevention: true,
                    postfix: "",
                    imageUploader: {
                    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                    allowUrls: true
                    },
                    onDemand: true,
                    discardSelector: ".discard-answer"
                    ,immediatelyShowMarkdownHelp:true
                    });


                    }
                    });














                    draft saved

                    draft discarded


















                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7935456%2finput-type-image-submit-form-value%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown

























                    12 Answers
                    12






                    active

                    oldest

                    votes








                    12 Answers
                    12






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes









                    52














                    An input type="image" only defines that image as the submit button and not as an input that can carry over a value to the server.






                    share|improve this answer
























                    • So, what can I use where I can use an image?

                      – Satch3000
                      Oct 28 '11 at 22:24











                    • Just to clear your question a bit more, are you trying to submit the image itself to the server?

                      – Francisco Paulo
                      Oct 28 '11 at 22:26











                    • No, I have an image as a button (or want to), so if the user clicks this image it adds a value from value="myvalue" and this value will be submitted with the form. So instead of using an input box or a checkbox or other I'm trying to use an image.

                      – Satch3000
                      Oct 28 '11 at 22:29






                    • 12





                      Ok. I don't think that the behaviour of browsers regarding the value in an image input is the same across the board. I would use an input="hidden" to keep the value, that way the user would just see the image and you could be sure that the value would be submitted.

                      – Francisco Paulo
                      Oct 28 '11 at 22:38
















                    52














                    An input type="image" only defines that image as the submit button and not as an input that can carry over a value to the server.






                    share|improve this answer
























                    • So, what can I use where I can use an image?

                      – Satch3000
                      Oct 28 '11 at 22:24











                    • Just to clear your question a bit more, are you trying to submit the image itself to the server?

                      – Francisco Paulo
                      Oct 28 '11 at 22:26











                    • No, I have an image as a button (or want to), so if the user clicks this image it adds a value from value="myvalue" and this value will be submitted with the form. So instead of using an input box or a checkbox or other I'm trying to use an image.

                      – Satch3000
                      Oct 28 '11 at 22:29






                    • 12





                      Ok. I don't think that the behaviour of browsers regarding the value in an image input is the same across the board. I would use an input="hidden" to keep the value, that way the user would just see the image and you could be sure that the value would be submitted.

                      – Francisco Paulo
                      Oct 28 '11 at 22:38














                    52












                    52








                    52







                    An input type="image" only defines that image as the submit button and not as an input that can carry over a value to the server.






                    share|improve this answer













                    An input type="image" only defines that image as the submit button and not as an input that can carry over a value to the server.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Oct 28 '11 at 22:22









                    Francisco PauloFrancisco Paulo

                    5,6902024




                    5,6902024













                    • So, what can I use where I can use an image?

                      – Satch3000
                      Oct 28 '11 at 22:24











                    • Just to clear your question a bit more, are you trying to submit the image itself to the server?

                      – Francisco Paulo
                      Oct 28 '11 at 22:26











                    • No, I have an image as a button (or want to), so if the user clicks this image it adds a value from value="myvalue" and this value will be submitted with the form. So instead of using an input box or a checkbox or other I'm trying to use an image.

                      – Satch3000
                      Oct 28 '11 at 22:29






                    • 12





                      Ok. I don't think that the behaviour of browsers regarding the value in an image input is the same across the board. I would use an input="hidden" to keep the value, that way the user would just see the image and you could be sure that the value would be submitted.

                      – Francisco Paulo
                      Oct 28 '11 at 22:38



















                    • So, what can I use where I can use an image?

                      – Satch3000
                      Oct 28 '11 at 22:24











                    • Just to clear your question a bit more, are you trying to submit the image itself to the server?

                      – Francisco Paulo
                      Oct 28 '11 at 22:26











                    • No, I have an image as a button (or want to), so if the user clicks this image it adds a value from value="myvalue" and this value will be submitted with the form. So instead of using an input box or a checkbox or other I'm trying to use an image.

                      – Satch3000
                      Oct 28 '11 at 22:29






                    • 12





                      Ok. I don't think that the behaviour of browsers regarding the value in an image input is the same across the board. I would use an input="hidden" to keep the value, that way the user would just see the image and you could be sure that the value would be submitted.

                      – Francisco Paulo
                      Oct 28 '11 at 22:38

















                    So, what can I use where I can use an image?

                    – Satch3000
                    Oct 28 '11 at 22:24





                    So, what can I use where I can use an image?

                    – Satch3000
                    Oct 28 '11 at 22:24













                    Just to clear your question a bit more, are you trying to submit the image itself to the server?

                    – Francisco Paulo
                    Oct 28 '11 at 22:26





                    Just to clear your question a bit more, are you trying to submit the image itself to the server?

                    – Francisco Paulo
                    Oct 28 '11 at 22:26













                    No, I have an image as a button (or want to), so if the user clicks this image it adds a value from value="myvalue" and this value will be submitted with the form. So instead of using an input box or a checkbox or other I'm trying to use an image.

                    – Satch3000
                    Oct 28 '11 at 22:29





                    No, I have an image as a button (or want to), so if the user clicks this image it adds a value from value="myvalue" and this value will be submitted with the form. So instead of using an input box or a checkbox or other I'm trying to use an image.

                    – Satch3000
                    Oct 28 '11 at 22:29




                    12




                    12





                    Ok. I don't think that the behaviour of browsers regarding the value in an image input is the same across the board. I would use an input="hidden" to keep the value, that way the user would just see the image and you could be sure that the value would be submitted.

                    – Francisco Paulo
                    Oct 28 '11 at 22:38





                    Ok. I don't think that the behaviour of browsers regarding the value in an image input is the same across the board. I would use an input="hidden" to keep the value, that way the user would just see the image and you could be sure that the value would be submitted.

                    – Francisco Paulo
                    Oct 28 '11 at 22:38













                    34














                    Using the type="image" is problematic because the ability to pass a value is disabled for some stupid lack of reason. Anyways & although it's not as customizable & thus as pretty, you can still use you images so long as they are part of a type="button".



                    <button type="submit" name="someName" value="someValue"><img src="someImage.png" alt="SomeAlternateText"></button>


                    Hope this helps! ^_^






                    share|improve this answer



















                    • 4





                      If you do this I believe you need to add a border="0" else some browsers might add an ugly bordered window

                      – Dynelight
                      Apr 10 '13 at 14:00






                    • 5





                      "Some browsers"? I wonder which ones :P

                      – Kenton de Jong
                      Nov 12 '13 at 20:13
















                    34














                    Using the type="image" is problematic because the ability to pass a value is disabled for some stupid lack of reason. Anyways & although it's not as customizable & thus as pretty, you can still use you images so long as they are part of a type="button".



                    <button type="submit" name="someName" value="someValue"><img src="someImage.png" alt="SomeAlternateText"></button>


                    Hope this helps! ^_^






                    share|improve this answer



















                    • 4





                      If you do this I believe you need to add a border="0" else some browsers might add an ugly bordered window

                      – Dynelight
                      Apr 10 '13 at 14:00






                    • 5





                      "Some browsers"? I wonder which ones :P

                      – Kenton de Jong
                      Nov 12 '13 at 20:13














                    34












                    34








                    34







                    Using the type="image" is problematic because the ability to pass a value is disabled for some stupid lack of reason. Anyways & although it's not as customizable & thus as pretty, you can still use you images so long as they are part of a type="button".



                    <button type="submit" name="someName" value="someValue"><img src="someImage.png" alt="SomeAlternateText"></button>


                    Hope this helps! ^_^






                    share|improve this answer













                    Using the type="image" is problematic because the ability to pass a value is disabled for some stupid lack of reason. Anyways & although it's not as customizable & thus as pretty, you can still use you images so long as they are part of a type="button".



                    <button type="submit" name="someName" value="someValue"><img src="someImage.png" alt="SomeAlternateText"></button>


                    Hope this helps! ^_^







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 30 '13 at 12:13









                    BoyBlueSkyBoyBlueSky

                    47144




                    47144








                    • 4





                      If you do this I believe you need to add a border="0" else some browsers might add an ugly bordered window

                      – Dynelight
                      Apr 10 '13 at 14:00






                    • 5





                      "Some browsers"? I wonder which ones :P

                      – Kenton de Jong
                      Nov 12 '13 at 20:13














                    • 4





                      If you do this I believe you need to add a border="0" else some browsers might add an ugly bordered window

                      – Dynelight
                      Apr 10 '13 at 14:00






                    • 5





                      "Some browsers"? I wonder which ones :P

                      – Kenton de Jong
                      Nov 12 '13 at 20:13








                    4




                    4





                    If you do this I believe you need to add a border="0" else some browsers might add an ugly bordered window

                    – Dynelight
                    Apr 10 '13 at 14:00





                    If you do this I believe you need to add a border="0" else some browsers might add an ugly bordered window

                    – Dynelight
                    Apr 10 '13 at 14:00




                    5




                    5





                    "Some browsers"? I wonder which ones :P

                    – Kenton de Jong
                    Nov 12 '13 at 20:13





                    "Some browsers"? I wonder which ones :P

                    – Kenton de Jong
                    Nov 12 '13 at 20:13











                    7














                    I was in the same place as you, finally I found a neat answer :



                    <form action="xx/xx" method="POST">
                    <input type="hidden" name="what you want" value="what you want">
                    <input type="image" src="xx.xx">
                    </form>





                    share|improve this answer




























                      7














                      I was in the same place as you, finally I found a neat answer :



                      <form action="xx/xx" method="POST">
                      <input type="hidden" name="what you want" value="what you want">
                      <input type="image" src="xx.xx">
                      </form>





                      share|improve this answer


























                        7












                        7








                        7







                        I was in the same place as you, finally I found a neat answer :



                        <form action="xx/xx" method="POST">
                        <input type="hidden" name="what you want" value="what you want">
                        <input type="image" src="xx.xx">
                        </form>





                        share|improve this answer













                        I was in the same place as you, finally I found a neat answer :



                        <form action="xx/xx" method="POST">
                        <input type="hidden" name="what you want" value="what you want">
                        <input type="image" src="xx.xx">
                        </form>






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Apr 11 '14 at 15:05









                        jungwookjungwook

                        31143




                        31143























                            6














                            I've found that image-buttons DO return a response, but you should NOT use a value-option. What I see returned are two version of the name="MYNAME" with .X and .Y endings.



                            For example:



                            <input type="image" src="/path-to/stop.png" name="STOP" width="25" height="25" align="top" alt="Stop sign">


                            This is within your <form> to </form>. If you click the image, what's returned are STOP.X and STOP.Y with numeric values. The existence of either indicates the STOP image-button was clicked. You don't need any special code. Just treat it as another kind of "submit" button that returns a pair of augmented NAMEs.



                            I've tried this on Safari, Firefox and Chrome. The image wasn't displayed with Safari, but where it was supposed to be located, my cursor turned into a finger-icon, and I could click it.






                            share|improve this answer






























                              6














                              I've found that image-buttons DO return a response, but you should NOT use a value-option. What I see returned are two version of the name="MYNAME" with .X and .Y endings.



                              For example:



                              <input type="image" src="/path-to/stop.png" name="STOP" width="25" height="25" align="top" alt="Stop sign">


                              This is within your <form> to </form>. If you click the image, what's returned are STOP.X and STOP.Y with numeric values. The existence of either indicates the STOP image-button was clicked. You don't need any special code. Just treat it as another kind of "submit" button that returns a pair of augmented NAMEs.



                              I've tried this on Safari, Firefox and Chrome. The image wasn't displayed with Safari, but where it was supposed to be located, my cursor turned into a finger-icon, and I could click it.






                              share|improve this answer




























                                6












                                6








                                6







                                I've found that image-buttons DO return a response, but you should NOT use a value-option. What I see returned are two version of the name="MYNAME" with .X and .Y endings.



                                For example:



                                <input type="image" src="/path-to/stop.png" name="STOP" width="25" height="25" align="top" alt="Stop sign">


                                This is within your <form> to </form>. If you click the image, what's returned are STOP.X and STOP.Y with numeric values. The existence of either indicates the STOP image-button was clicked. You don't need any special code. Just treat it as another kind of "submit" button that returns a pair of augmented NAMEs.



                                I've tried this on Safari, Firefox and Chrome. The image wasn't displayed with Safari, but where it was supposed to be located, my cursor turned into a finger-icon, and I could click it.






                                share|improve this answer















                                I've found that image-buttons DO return a response, but you should NOT use a value-option. What I see returned are two version of the name="MYNAME" with .X and .Y endings.



                                For example:



                                <input type="image" src="/path-to/stop.png" name="STOP" width="25" height="25" align="top" alt="Stop sign">


                                This is within your <form> to </form>. If you click the image, what's returned are STOP.X and STOP.Y with numeric values. The existence of either indicates the STOP image-button was clicked. You don't need any special code. Just treat it as another kind of "submit" button that returns a pair of augmented NAMEs.



                                I've tried this on Safari, Firefox and Chrome. The image wasn't displayed with Safari, but where it was supposed to be located, my cursor turned into a finger-icon, and I could click it.







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Jan 4 '18 at 8:14









                                Shashanth

                                2,56242236




                                2,56242236










                                answered Jul 4 '14 at 15:54









                                Dick GuertinDick Guertin

                                50658




                                50658























                                    4














                                    Some browsers (IIRC it is just some versions of Internet Explorer) only send the co-ordinates of the image map (in name.x and name.y) and ignore the value. This is a bug.



                                    The workarounds are to either:




                                    • Have only one submit button and use a hidden input to sent the value

                                    • Use regular submit buttons instead of image maps

                                    • Use unique names instead of values and check for the presence of name.x / name.y






                                    share|improve this answer






























                                      4














                                      Some browsers (IIRC it is just some versions of Internet Explorer) only send the co-ordinates of the image map (in name.x and name.y) and ignore the value. This is a bug.



                                      The workarounds are to either:




                                      • Have only one submit button and use a hidden input to sent the value

                                      • Use regular submit buttons instead of image maps

                                      • Use unique names instead of values and check for the presence of name.x / name.y






                                      share|improve this answer




























                                        4












                                        4








                                        4







                                        Some browsers (IIRC it is just some versions of Internet Explorer) only send the co-ordinates of the image map (in name.x and name.y) and ignore the value. This is a bug.



                                        The workarounds are to either:




                                        • Have only one submit button and use a hidden input to sent the value

                                        • Use regular submit buttons instead of image maps

                                        • Use unique names instead of values and check for the presence of name.x / name.y






                                        share|improve this answer















                                        Some browsers (IIRC it is just some versions of Internet Explorer) only send the co-ordinates of the image map (in name.x and name.y) and ignore the value. This is a bug.



                                        The workarounds are to either:




                                        • Have only one submit button and use a hidden input to sent the value

                                        • Use regular submit buttons instead of image maps

                                        • Use unique names instead of values and check for the presence of name.x / name.y







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited Oct 28 '11 at 22:33

























                                        answered Oct 28 '11 at 22:22









                                        QuentinQuentin

                                        650k728821044




                                        650k728821044























                                            3














                                            Here is what I was trying to do and how I did it. I think you wanted to do something similar.
                                            I had a table with several rows and on each row I had an input with type image. I wanted to pass an id when the user clicked that image button. As you noticed the value in the tag is ignored. Instead I added a hidden input at the top of my table and using javascript I put the correct id there before I post the form.



                                            <input type="image" onclick="$('#hiddenInput').val(rowId) src="...">


                                            This way the correct id will be submitted with your form.






                                            share|improve this answer




























                                              3














                                              Here is what I was trying to do and how I did it. I think you wanted to do something similar.
                                              I had a table with several rows and on each row I had an input with type image. I wanted to pass an id when the user clicked that image button. As you noticed the value in the tag is ignored. Instead I added a hidden input at the top of my table and using javascript I put the correct id there before I post the form.



                                              <input type="image" onclick="$('#hiddenInput').val(rowId) src="...">


                                              This way the correct id will be submitted with your form.






                                              share|improve this answer


























                                                3












                                                3








                                                3







                                                Here is what I was trying to do and how I did it. I think you wanted to do something similar.
                                                I had a table with several rows and on each row I had an input with type image. I wanted to pass an id when the user clicked that image button. As you noticed the value in the tag is ignored. Instead I added a hidden input at the top of my table and using javascript I put the correct id there before I post the form.



                                                <input type="image" onclick="$('#hiddenInput').val(rowId) src="...">


                                                This way the correct id will be submitted with your form.






                                                share|improve this answer













                                                Here is what I was trying to do and how I did it. I think you wanted to do something similar.
                                                I had a table with several rows and on each row I had an input with type image. I wanted to pass an id when the user clicked that image button. As you noticed the value in the tag is ignored. Instead I added a hidden input at the top of my table and using javascript I put the correct id there before I post the form.



                                                <input type="image" onclick="$('#hiddenInput').val(rowId) src="...">


                                                This way the correct id will be submitted with your form.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered May 12 '14 at 14:11









                                                cogeocogeo

                                                3114




                                                3114























                                                    1














                                                    You could use a radio button/checkbox and set it to hide the button in css and then give it a label with an image.



                                                    input[type="radio"] {display: none}
                                                    input[type="radio"] + label span {display: block}


                                                    Then on the page:



                                                    <input type="radio" name="emotion" id="mysubmitradio" />
                                                    <label for="mysubmitradio"><img src="images/f.jpg" />
                                                    <span>if you need it</span></label>


                                                    And then set it to submit using javascript:



                                                    document.forms["myform"].submit();





                                                    share|improve this answer




























                                                      1














                                                      You could use a radio button/checkbox and set it to hide the button in css and then give it a label with an image.



                                                      input[type="radio"] {display: none}
                                                      input[type="radio"] + label span {display: block}


                                                      Then on the page:



                                                      <input type="radio" name="emotion" id="mysubmitradio" />
                                                      <label for="mysubmitradio"><img src="images/f.jpg" />
                                                      <span>if you need it</span></label>


                                                      And then set it to submit using javascript:



                                                      document.forms["myform"].submit();





                                                      share|improve this answer


























                                                        1












                                                        1








                                                        1







                                                        You could use a radio button/checkbox and set it to hide the button in css and then give it a label with an image.



                                                        input[type="radio"] {display: none}
                                                        input[type="radio"] + label span {display: block}


                                                        Then on the page:



                                                        <input type="radio" name="emotion" id="mysubmitradio" />
                                                        <label for="mysubmitradio"><img src="images/f.jpg" />
                                                        <span>if you need it</span></label>


                                                        And then set it to submit using javascript:



                                                        document.forms["myform"].submit();





                                                        share|improve this answer













                                                        You could use a radio button/checkbox and set it to hide the button in css and then give it a label with an image.



                                                        input[type="radio"] {display: none}
                                                        input[type="radio"] + label span {display: block}


                                                        Then on the page:



                                                        <input type="radio" name="emotion" id="mysubmitradio" />
                                                        <label for="mysubmitradio"><img src="images/f.jpg" />
                                                        <span>if you need it</span></label>


                                                        And then set it to submit using javascript:



                                                        document.forms["myform"].submit();






                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Apr 4 '13 at 4:44









                                                        Neil Philip WhiteheadNeil Philip Whitehead

                                                        4421311




                                                        4421311























                                                            1














                                                            Solution:



                                                            <form name="frmSeguimiento" id="frmSeguimiento" method="post" action="proc_seguimiento.php">  
                                                            <input type="hidden" name="accion" id="accion"/>


                                                            <input name="save" type="image" src="imagenes/save.png" alt="Save" onmouseover="this.src='imagenes/save_over.png';" onmouseout="this.src='imagenes/save.png';" value="Save" onclick="validaFrmSeguimiento(this.value);"/>


                                                            function validaFrmSeguimiento(accion)
                                                            {
                                                            document.frmSeguimiento.accion.value=accion;

                                                            }


                                                            Regards,
                                                            jp






                                                            share|improve this answer




























                                                              1














                                                              Solution:



                                                              <form name="frmSeguimiento" id="frmSeguimiento" method="post" action="proc_seguimiento.php">  
                                                              <input type="hidden" name="accion" id="accion"/>


                                                              <input name="save" type="image" src="imagenes/save.png" alt="Save" onmouseover="this.src='imagenes/save_over.png';" onmouseout="this.src='imagenes/save.png';" value="Save" onclick="validaFrmSeguimiento(this.value);"/>


                                                              function validaFrmSeguimiento(accion)
                                                              {
                                                              document.frmSeguimiento.accion.value=accion;

                                                              }


                                                              Regards,
                                                              jp






                                                              share|improve this answer


























                                                                1












                                                                1








                                                                1







                                                                Solution:



                                                                <form name="frmSeguimiento" id="frmSeguimiento" method="post" action="proc_seguimiento.php">  
                                                                <input type="hidden" name="accion" id="accion"/>


                                                                <input name="save" type="image" src="imagenes/save.png" alt="Save" onmouseover="this.src='imagenes/save_over.png';" onmouseout="this.src='imagenes/save.png';" value="Save" onclick="validaFrmSeguimiento(this.value);"/>


                                                                function validaFrmSeguimiento(accion)
                                                                {
                                                                document.frmSeguimiento.accion.value=accion;

                                                                }


                                                                Regards,
                                                                jp






                                                                share|improve this answer













                                                                Solution:



                                                                <form name="frmSeguimiento" id="frmSeguimiento" method="post" action="proc_seguimiento.php">  
                                                                <input type="hidden" name="accion" id="accion"/>


                                                                <input name="save" type="image" src="imagenes/save.png" alt="Save" onmouseover="this.src='imagenes/save_over.png';" onmouseout="this.src='imagenes/save.png';" value="Save" onclick="validaFrmSeguimiento(this.value);"/>


                                                                function validaFrmSeguimiento(accion)
                                                                {
                                                                document.frmSeguimiento.accion.value=accion;

                                                                }


                                                                Regards,
                                                                jp







                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered Aug 11 '16 at 2:12









                                                                Juan Paez GallardoJuan Paez Gallardo

                                                                111




                                                                111























                                                                    1














                                                                    Inputs of type="image" don't send their name/value pair when used to submit the form. To me, that sounds like a bug, but that's how it is.



                                                                    To get around this, you can replace the input with a button of type="submit", and put a img element inside.



                                                                    Unfortunately, that causes your image to be in a ugly HTML "button". However, assuming you aren't using the standard HTML button anywhere, you can just override the stylesheet, and then everything should work as expected:






                                                                    button, input[type="submit"], input[type="reset"] {
                                                                    background: none;
                                                                    color: inherit;
                                                                    border: none;
                                                                    padding: 0;
                                                                    font: inherit;
                                                                    cursor: pointer;
                                                                    outline: inherit;
                                                                    }

                                                                    <form action="/post">
                                                                    <input name="test">
                                                                    <button type="submit" name="submit_button" value="submitted">
                                                                    <img src="https://via.placeholder.com/32" alt="image">
                                                                    </button>
                                                                    </form>








                                                                    share|improve this answer




























                                                                      1














                                                                      Inputs of type="image" don't send their name/value pair when used to submit the form. To me, that sounds like a bug, but that's how it is.



                                                                      To get around this, you can replace the input with a button of type="submit", and put a img element inside.



                                                                      Unfortunately, that causes your image to be in a ugly HTML "button". However, assuming you aren't using the standard HTML button anywhere, you can just override the stylesheet, and then everything should work as expected:






                                                                      button, input[type="submit"], input[type="reset"] {
                                                                      background: none;
                                                                      color: inherit;
                                                                      border: none;
                                                                      padding: 0;
                                                                      font: inherit;
                                                                      cursor: pointer;
                                                                      outline: inherit;
                                                                      }

                                                                      <form action="/post">
                                                                      <input name="test">
                                                                      <button type="submit" name="submit_button" value="submitted">
                                                                      <img src="https://via.placeholder.com/32" alt="image">
                                                                      </button>
                                                                      </form>








                                                                      share|improve this answer


























                                                                        1












                                                                        1








                                                                        1







                                                                        Inputs of type="image" don't send their name/value pair when used to submit the form. To me, that sounds like a bug, but that's how it is.



                                                                        To get around this, you can replace the input with a button of type="submit", and put a img element inside.



                                                                        Unfortunately, that causes your image to be in a ugly HTML "button". However, assuming you aren't using the standard HTML button anywhere, you can just override the stylesheet, and then everything should work as expected:






                                                                        button, input[type="submit"], input[type="reset"] {
                                                                        background: none;
                                                                        color: inherit;
                                                                        border: none;
                                                                        padding: 0;
                                                                        font: inherit;
                                                                        cursor: pointer;
                                                                        outline: inherit;
                                                                        }

                                                                        <form action="/post">
                                                                        <input name="test">
                                                                        <button type="submit" name="submit_button" value="submitted">
                                                                        <img src="https://via.placeholder.com/32" alt="image">
                                                                        </button>
                                                                        </form>








                                                                        share|improve this answer













                                                                        Inputs of type="image" don't send their name/value pair when used to submit the form. To me, that sounds like a bug, but that's how it is.



                                                                        To get around this, you can replace the input with a button of type="submit", and put a img element inside.



                                                                        Unfortunately, that causes your image to be in a ugly HTML "button". However, assuming you aren't using the standard HTML button anywhere, you can just override the stylesheet, and then everything should work as expected:






                                                                        button, input[type="submit"], input[type="reset"] {
                                                                        background: none;
                                                                        color: inherit;
                                                                        border: none;
                                                                        padding: 0;
                                                                        font: inherit;
                                                                        cursor: pointer;
                                                                        outline: inherit;
                                                                        }

                                                                        <form action="/post">
                                                                        <input name="test">
                                                                        <button type="submit" name="submit_button" value="submitted">
                                                                        <img src="https://via.placeholder.com/32" alt="image">
                                                                        </button>
                                                                        </form>








                                                                        button, input[type="submit"], input[type="reset"] {
                                                                        background: none;
                                                                        color: inherit;
                                                                        border: none;
                                                                        padding: 0;
                                                                        font: inherit;
                                                                        cursor: pointer;
                                                                        outline: inherit;
                                                                        }

                                                                        <form action="/post">
                                                                        <input name="test">
                                                                        <button type="submit" name="submit_button" value="submitted">
                                                                        <img src="https://via.placeholder.com/32" alt="image">
                                                                        </button>
                                                                        </form>





                                                                        button, input[type="submit"], input[type="reset"] {
                                                                        background: none;
                                                                        color: inherit;
                                                                        border: none;
                                                                        padding: 0;
                                                                        font: inherit;
                                                                        cursor: pointer;
                                                                        outline: inherit;
                                                                        }

                                                                        <form action="/post">
                                                                        <input name="test">
                                                                        <button type="submit" name="submit_button" value="submitted">
                                                                        <img src="https://via.placeholder.com/32" alt="image">
                                                                        </button>
                                                                        </form>






                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered Nov 14 '18 at 23:45









                                                                        SkeetsSkeets

                                                                        1,6061531




                                                                        1,6061531























                                                                            0














                                                                            well if i was in your place i would do this.I would have an hidden field and based on the input image field i would change the hidden field value(jQuery), and then finally submit the hidden field whose value reflects the image field.






                                                                            share|improve this answer




























                                                                              0














                                                                              well if i was in your place i would do this.I would have an hidden field and based on the input image field i would change the hidden field value(jQuery), and then finally submit the hidden field whose value reflects the image field.






                                                                              share|improve this answer


























                                                                                0












                                                                                0








                                                                                0







                                                                                well if i was in your place i would do this.I would have an hidden field and based on the input image field i would change the hidden field value(jQuery), and then finally submit the hidden field whose value reflects the image field.






                                                                                share|improve this answer













                                                                                well if i was in your place i would do this.I would have an hidden field and based on the input image field i would change the hidden field value(jQuery), and then finally submit the hidden field whose value reflects the image field.







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Oct 13 '14 at 10:37









                                                                                MateenMateen

                                                                                685817




                                                                                685817























                                                                                    -2














                                                                                    Add this



                                                                                        name="myvalue"


                                                                                    To your tag.






                                                                                    share|improve this answer




























                                                                                      -2














                                                                                      Add this



                                                                                          name="myvalue"


                                                                                      To your tag.






                                                                                      share|improve this answer


























                                                                                        -2












                                                                                        -2








                                                                                        -2







                                                                                        Add this



                                                                                            name="myvalue"


                                                                                        To your tag.






                                                                                        share|improve this answer













                                                                                        Add this



                                                                                            name="myvalue"


                                                                                        To your tag.







                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered Apr 17 '14 at 5:36









                                                                                        San BergamSan Bergam

                                                                                        192




                                                                                        192























                                                                                            -7














                                                                                            To submit a form you could use:



                                                                                            <input type="submit">


                                                                                            or



                                                                                            <input type="button"> + Javascript 


                                                                                            I never heard of such a crazy guy to try to send a form using a image or a checkbox as you want :))






                                                                                            share|improve this answer


























                                                                                            • Damn Daniel, hear now

                                                                                              – Tilak Maddy
                                                                                              May 10 '17 at 16:42
















                                                                                            -7














                                                                                            To submit a form you could use:



                                                                                            <input type="submit">


                                                                                            or



                                                                                            <input type="button"> + Javascript 


                                                                                            I never heard of such a crazy guy to try to send a form using a image or a checkbox as you want :))






                                                                                            share|improve this answer


























                                                                                            • Damn Daniel, hear now

                                                                                              – Tilak Maddy
                                                                                              May 10 '17 at 16:42














                                                                                            -7












                                                                                            -7








                                                                                            -7







                                                                                            To submit a form you could use:



                                                                                            <input type="submit">


                                                                                            or



                                                                                            <input type="button"> + Javascript 


                                                                                            I never heard of such a crazy guy to try to send a form using a image or a checkbox as you want :))






                                                                                            share|improve this answer















                                                                                            To submit a form you could use:



                                                                                            <input type="submit">


                                                                                            or



                                                                                            <input type="button"> + Javascript 


                                                                                            I never heard of such a crazy guy to try to send a form using a image or a checkbox as you want :))







                                                                                            share|improve this answer














                                                                                            share|improve this answer



                                                                                            share|improve this answer








                                                                                            edited Jun 7 '13 at 12:13









                                                                                            Liam

                                                                                            16.3k1676129




                                                                                            16.3k1676129










                                                                                            answered Jun 7 '13 at 11:55









                                                                                            Florin DanielFlorin Daniel

                                                                                            71




                                                                                            71













                                                                                            • Damn Daniel, hear now

                                                                                              – Tilak Maddy
                                                                                              May 10 '17 at 16:42



















                                                                                            • Damn Daniel, hear now

                                                                                              – Tilak Maddy
                                                                                              May 10 '17 at 16:42

















                                                                                            Damn Daniel, hear now

                                                                                            – Tilak Maddy
                                                                                            May 10 '17 at 16:42





                                                                                            Damn Daniel, hear now

                                                                                            – Tilak Maddy
                                                                                            May 10 '17 at 16:42


















                                                                                            draft saved

                                                                                            draft discarded




















































                                                                                            Thanks for contributing an answer to Stack Overflow!


                                                                                            • Please be sure to answer the question. Provide details and share your research!

                                                                                            But avoid



                                                                                            • Asking for help, clarification, or responding to other answers.

                                                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                                                            To learn more, see our tips on writing great answers.




                                                                                            draft saved


                                                                                            draft discarded














                                                                                            StackExchange.ready(
                                                                                            function () {
                                                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7935456%2finput-type-image-submit-form-value%23new-answer', 'question_page');
                                                                                            }
                                                                                            );

                                                                                            Post as a guest















                                                                                            Required, but never shown





















































                                                                                            Required, but never shown














                                                                                            Required, but never shown












                                                                                            Required, but never shown







                                                                                            Required, but never shown

































                                                                                            Required, but never shown














                                                                                            Required, but never shown












                                                                                            Required, but never shown







                                                                                            Required, but never shown







                                                                                            Popular posts from this blog

                                                                                            Florida Star v. B. J. F.

                                                                                            Error while running script in elastic search , gateway timeout

                                                                                            Adding quotations to stringified JSON object values