Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input Type image submit form value?

Tags:

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

like image 678
Satch3000 Avatar asked Oct 28 '11 22:10

Satch3000


People also ask

Can you use an image as a submit button?

Definition and UsageThe <input type="image"> defines an image as a submit button. The path to the image is specified in the src attribute.


2 Answers

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.

like image 66
Francisco Paulo Avatar answered Sep 29 '22 09:09

Francisco Paulo


Using the type="image" is problematic because the ability to pass a value is disabled. Although it's not as customizable and thus as pretty, you can still use your images ao long as they are part of a type="button".

<button type="submit" name="someName" value="someValue"><img src="someImage.png" alt="SomeAlternateText"></button> 
like image 41
BoyBlueSky Avatar answered Sep 29 '22 09:09

BoyBlueSky