0

How can I add html value for select menu options:

<select name="symbol">
  <option>select</option>
  <option value="<img src="start.jpg"">start</option>
  <option value="<img src="end.jpg"">end</option>
</select>

I want post value to show an image.

I read this : How to add a images in select list but I want send image value.

Community
  • 1
  • 1

3 Answers3

0

Use single quotes instead of double qoutes inside value...

<select name="symbol">
  <option>select</option>
  <option value="<img src='b.jpg'>">start</option>
  <option value="<img src='a.jpg'>">end</option>
</select>
Sherin Jose
  • 2,508
  • 3
  • 18
  • 39
0

If you're handling the post with PHP or some similar server-side code, you should pass through only the reference to the image. Any tags can be output using the server-side code. For example:

<select name="symbol">
    <option>select</option>
    <option value="start.jpg">start</option>
    <option value="end.jpg">end</option>
</select>

And then handle this by doing something like:

echo '<img src="'.$_POST['symbol'].'" />';
BenM
  • 52,573
  • 26
  • 113
  • 168
0

You have to use single quote and close tag. Try this,

<select name="symbol">
          <option>select</option>
          <option value="<img src='start.jpg'>">start</option>
          <option value="<img src='end.jpg'>">end</option>
</select>
Edwin Alex
  • 5,118
  • 4
  • 28
  • 50