Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image in dropdown list 1

Status
Not open for further replies.

shiggyshag

Programmer
Dec 14, 2001
227
GB
Hi

I have a Select option on my page and want to show images instead of text.

I.e
<select name=&quot;test&quot;>
<option value=&quot;:)&quot;>&quot;><img src=&quot;faces/smile.gif&quot;></option>
</select>

any ideas

cheers
 
I don't know if it's possible with a drop-down list, but another good solution is using radio buttons. Maybe you can try this:

<input type=&quot;radio&quot; name=&quot;smileys&quot; value=&quot;:)&quot;><img src=&quot;faces/smile.gif&quot;>
<input type=&quot;radio&quot; name=&quot;smileys&quot; value=&quot;:(&quot;><img src=&quot;faces/sad.gif&quot;>

This should work really fine. Make sure you use the same name for all the radio buttons in one group.

Greetings,
Steven
 
Sorry, but Stoemp is entirely correct. Select boxes only handle plain text (no html tags at all). Another option, however, is to have a dropdown like this:
Code:
<select name=&quot;selPic&quot; onClick=&quot;imgPreview.src='faces/'+this.options[this.selectedIndex].text+'.gif';imgPreview.alt=this.text+' face';&quot;>
   <option value=&quot;:)&quot;>smile</option>
   <option value=&quot;:(&quot;>frown</option>
</select>
<img src=&quot;faces/smile.gif&quot; name=&quot;imgPreview&quot;>

That will change the preview image to the selection from the dropdown as well as addig an alt tag to the preview.

hope that helps,
-tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
With enough resources, time, and coffee, anything is possible.
 
Thankyou both for your help I used Tarwn's idea

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top