PDA

View Full Version : ASP drop down box of images


aabruzzese
09-25-2002, 05:44 AM
Hello Everyone,

I am new to the forum and am looking for some help with VBSCRIT.

I am creating a drop down box with options populated from a database, what I am looking to do is to insert an <img =
tag as the option instead of the text in a field.

here is a snippet of the code:

' Build our drop down box of ships with name as value and a bitmap as option

If Not Ships.EOF Then
Ships.MoveFirst
%>
<select name="id">
<option></option>
<% ' Loop through names
Do While Not Ships.EOF
Response.Write "<option value="""
Response.Write Ships.Fields"Name")
Response.Write """"
If Ships.Fields("Name") = CIn (iRequestedID) Then
Response.Write "selected=""true"""
End If
Response.Write ">"
Response.Write("<img width=42 height=42 SRC='"& StrImgPath & Patrol & "'>")
Response.Write " "
Response.Write Trim(Ships.Fields ("Name"))
Response.Write "</option>" & vbCrLf

' Move to next record
Ships.MoveNext
Loop
%>
</select>
<%
End If

The part that is not working is the image, how do i code that so instead of showing the content of some field, i show an image I am pointing to.

Not : Patrol is pulled from the DB and contains the name of the bitmap and StrImgPath is a variable containing the path.


Any help would be greatly appreciated.


Angelo

glenngv
09-25-2002, 06:14 AM
you can't put an <img> tag inside the <option> tag.

aabruzzese
09-25-2002, 12:11 PM
So basically your saying you cannot create a list of images as part of a combo box ?


I am sure there is an alternative, I might simply have to build
a datagrid or perhaps a table with a checkbox next to
each item.


Oh well back to the drawing board.


Angelo

whammy
09-26-2002, 12:38 AM
Yup. Glenn is right... although these things may be part of our future! (hopefully)

:D

P.S. You can create a list of LINKS to images though...

aabruzzese
09-26-2002, 12:48 AM
Thanks guys,

I guess I knew the answer all along and was just hoping that
things have changed over the years.

Hey when you really think of it, why would someone not have worked that into the HTML or Scripting language standards ?

Is it such an unreasonable idea to have a combo box comprised of images instead of text ?


Angelo
:rolleyes:

whammy
09-26-2002, 01:00 AM
I guess it is... for the time being.

But you could probably hack something like this on the server-side fairly easily.

aabruzzese
09-26-2002, 02:19 AM
Yup,

I am going to use the dictionary object and create objects
to hod the list that I want to display including images.

I will use functions to perform the add, delete, show and submit work.


Basically the idea is show a list of units and select the attacking units and thier corresponding targets.

Its part of a PBEM game I am setting up.


Angelo