Input Type image submit form value?
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
add a comment |
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
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
add a comment |
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
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
html forms
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
add a comment |
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
add a comment |
12 Answers
12
active
oldest
votes
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.
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
add a comment |
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! ^_^
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
add a comment |
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>
add a comment |
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.
add a comment |
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
add a comment |
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.
add a comment |
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();
add a comment |
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
add a comment |
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>
add a comment |
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.
add a comment |
Add this
name="myvalue"
To your tag.
add a comment |
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 :))
Damn Daniel, hear now
– Tilak Maddy
May 10 '17 at 16:42
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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! ^_^
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
add a comment |
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! ^_^
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
add a comment |
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! ^_^
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! ^_^
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
add a comment |
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
add a comment |
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>
add a comment |
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>
add a comment |
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>
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>
answered Apr 11 '14 at 15:05
jungwookjungwook
31143
31143
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited Jan 4 '18 at 8:14
Shashanth
2,56242236
2,56242236
answered Jul 4 '14 at 15:54
Dick GuertinDick Guertin
50658
50658
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
edited Oct 28 '11 at 22:33
answered Oct 28 '11 at 22:22
QuentinQuentin
650k728821044
650k728821044
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered May 12 '14 at 14:11
cogeocogeo
3114
3114
add a comment |
add a comment |
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();
add a comment |
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();
add a comment |
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();
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();
answered Apr 4 '13 at 4:44
Neil Philip WhiteheadNeil Philip Whitehead
4421311
4421311
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Aug 11 '16 at 2:12
Juan Paez GallardoJuan Paez Gallardo
111
111
add a comment |
add a comment |
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>
add a comment |
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>
add a comment |
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>
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>
answered Nov 14 '18 at 23:45
SkeetsSkeets
1,6061531
1,6061531
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Oct 13 '14 at 10:37
MateenMateen
685817
685817
add a comment |
add a comment |
Add this
name="myvalue"
To your tag.
add a comment |
Add this
name="myvalue"
To your tag.
add a comment |
Add this
name="myvalue"
To your tag.
Add this
name="myvalue"
To your tag.
answered Apr 17 '14 at 5:36
San BergamSan Bergam
192
192
add a comment |
add a comment |
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 :))
Damn Daniel, hear now
– Tilak Maddy
May 10 '17 at 16:42
add a comment |
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 :))
Damn Daniel, hear now
– Tilak Maddy
May 10 '17 at 16:42
add a comment |
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 :))
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 :))
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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