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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace result value with an image

Status
Not open for further replies.

meltingpot

Technical User
May 11, 2004
118
GB
Im trying to replace the result field "first" with an image file, say GIF.

The field returns a true/false value. I would like to replace true with an image of a tick and the false with an image of a x .. can anybody help ?

<td class="dottedlines style1"><%=(course_pending.Fields.Item("First").Value)%></td>


:)
 
Thanks ChristHurst ... Im not sure how to fit this in to my code , im new to this so bear with me :)..Do I need to replcae 'value' with something ?
 
This is what I would do:

Since you said 'course_pending.Fields.Item("First").Value' returns either a true or false and dependent upon that value determines what image gets shown in the <td>, do a terniary operator like this:

Code:
<td class="dottedlines style1">
[!]<%=((course_pending.Fields.Item("First").value ? "<img src='tick.gif' alt='True'>" : "<img src='cross.gif' alt='False'>")%>
[/!]
</td>
It's basically the same thing ChrisHirst put, it's just inline.


<.

 
Tried ..but get the following error...
Error Type:
Microsoft VBScript compilation (0x800A0408)
Invalid character
/courses/c_app/course_allocate.asp, line 498, column 58
Response.Write(((course_pending.Fields.Item("First").value?"<img src='Last.gif' alt='True'>" : "<img src='First.gif' alt='False'>"))

Using the following code ....

<td class="dottedlines style1"><%=((course_pending.Fields.Item("First").value?"<img src='Last.gif' alt='True'>" : "<img src='First.gif' alt='False'>")%>
</td>

:)
 
><td class="dottedlines style1"><%=((course_pending.Fields.Item("First").value?"<img src='Last.gif' alt='True'>" : "<img src='First.gif' alt='False'>")%>

[tt]<td class="dottedlines style1"><% if cbool(course_pending.Fields.Item("First").value) then response.write "<img src='Last.gif' alt='True'>" else response.write "<img src='First.gif' alt='False'>" %>[/tt]

note: keep it in one line in order to spare "end if".
 
Many thanks ... tsuji, works fantastic and ive also learnt something

Cheers from southern england :)
 
OOPS, I need to look up my inline VBScript syntax, that was JScript.

<.

 
Heres another one chaps, How can I open a seperate browser window settings its width, height and if it has a menu at the same time sending the parameters below to it ?

<A HREF="course_second_choice_popup.asp?PersonID=<%=(course_pending.Fields.Item("PersonID").Value)%>&CourseID=<%= (course_pending.Fields.Item("CourseID").Value)%>" target="_blank"><img src="../images/xcross.gif" alt="second choice" border="0"></A>

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top