XSLT if help

C

CK

Hi Everyone,
I have a custom web part in SharePoint. I want a cell in the table to be
conditionally formatted. Using Front Page it's fairly easy to make general
formatting chnages, like color, italics, and bold, etc... My problem is that
I want to show an image in a cell. The image will be based on the content in
another cell. If the value of the cell is "Complete" I want to show image A,
if "In Progress" image B, and if "Other" then image C. Does anyone have any
examples of how to do this? Any links or sample code would be appreciated.

Thanks,
CK
 
P

Peter Flynn

CK said:
Hi Everyone,
I have a custom web part in SharePoint. I want a cell in the table to be
conditionally formatted. Using Front Page it's fairly easy to make general
formatting chnages, like color, italics, and bold, etc... My problem is that
I want to show an image in a cell. The image will be based on the content in
another cell. If the value of the cell is "Complete" I want to show image A,
if "In Progress" image B, and if "Other" then image C. Does anyone have any
examples of how to do this? Any links or sample code would be appreciated.

<img alt="whatever" width="x" height="y">
<xsl:attribute name="src">
<xsl:choose>
<xsl:when test="xpath/to/othercell='Complete'">
<xsl:text>A.gif</text>
</xsl:when>
<xsl:when test="xpath/to/othercell='In Progress'">
<xsl:text>B.gif</text>
</xsl:when>
<xsl:when test="xpath/to/othercell='Other'">
<xsl:text>C.gif</text>
</xsl:when>
<xsl:eek:therwise>
<xsl:text>error.gif</xsl:text>
</xsl:eek:therwise>
</xsl:choose>
</xsl:attribute>
</img>

A shorter way would be to rename the images Complete.gif,
In%20Progress.gif, and Other.gif, then just use the value of the
specified cell as the src attribute value.

///Peter
 
C

CK

Terrific. Thanks Peter
Peter Flynn said:
<img alt="whatever" width="x" height="y">
<xsl:attribute name="src">
<xsl:choose>
<xsl:when test="xpath/to/othercell='Complete'">
<xsl:text>A.gif</text>
</xsl:when>
<xsl:when test="xpath/to/othercell='In Progress'">
<xsl:text>B.gif</text>
</xsl:when>
<xsl:when test="xpath/to/othercell='Other'">
<xsl:text>C.gif</text>
</xsl:when>
<xsl:eek:therwise>
<xsl:text>error.gif</xsl:text>
</xsl:eek:therwise>
</xsl:choose>
</xsl:attribute>
</img>

A shorter way would be to rename the images Complete.gif,
In%20Progress.gif, and Other.gif, then just use the value of the
specified cell as the src attribute value.

///Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,255
Members
46,852
Latest member
CarlaDowle

Latest Threads

Top