Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

calling javascript from IMG tag

Avatar of sharepoint_new
sharepoint_new asked on
JScript
3 Comments1 Solution394 ViewsLast Modified:
Hi,
I have a requirement where i need to show gif images based on file extensions in attachments. For that I have written an  xsl where I am calling javascript to check the extension and pass the proper image for that particular extension. Somehow my image tag is not picking that.
I am attaching the code . Please can anyone help me
<SCRIPT LANGUAGE="javascript" DEFER="true">

      [CDATA[ 

		function GetIcon(myFileName)
	{
		var myIcon
		if(myFileName.indexOf(".doc") > -1)
		{
			myIcon = "http://dlglobal.dl.com/_layouts/images/icdoc.gif";
		}
		else if (myFileName.indexOf(".pdf") > -1)
		{
			myIcon = "http://dlglobal.dl.com/_layouts/images/pdf16.gif";
		}
		else if (myFileName.indexOf(".ppt") > -1)
		{
			myIcon = "http://dlglobal.dl.com/_layouts/images/icppt.gif";
		}
		else if (myFileName.indexOf(".xls") > -1)
		{
			myIcon = "http://dlglobal.dl.com/_layouts/images/icxls.gif";
		}

		else
		{
			myIcon = "http://dlglobal.dl.com/PR/BDMarketing/_layouts/AssetUploader.aspx?Size=Small&ImageUrl=%2fPR%2fBDMarketing%2fPublishingImages%2fLondonBrochure%2egif";
		}
		
		return myIcon;
	}

  ]]> 
   
   </SCRIPT>-->
   

<xsl:template match='/Rows'>
<xsl:apply-templates select='Row[position()&lt;=$maxitems]'>
</xsl:apply-templates>
</xsl:template>

<xsl:template match='Row'>
<table border="0" width="100%" cellpadding="2" cellspacing="0">
<tr valign="top">
<xsl:if test="position() = 1">
    <th style="background: #CBCCC0;color: #FFFFFF !important;text-align: center;text-decoration: none;vertical-align: top;font-family: Helvetica !important;font-size: 10pt;font-weight: bold;padding: 5px 5px 5px 15px;" width="75" nowrap="nowrap">Title</th> 
    <th style="background: #CBCCC0;color: #FFFFFF !important;text-align: center;text-decoration: none;vertical-align: top;font-family: Helvetica !important;font-size: 10pt;font-weight: bold;padding: 5px 5px 5px 15px;" width="75" nowrap="nowrap">Date</th> 
   <th style="background: #CBCCC0;color: #FFFFFF !important;text-align: center;text-decoration: none;vertical-align: top;font-family: Helvetica !important;font-size: 10pt;font-weight: bold;padding: 5px 5px 5px 15px;" width="75" nowrap="nowrap">Attachments</th> 
</xsl:if>
</tr>

<tr>
<td style="padding: 5px 5px 5px 15px" width="150" nowrap="false" >
  <xsl:value-of select="Title" /> 
  </td>
<td style="padding: 5px 5px 5px 15px" width="150" nowrap="false" >
  <xsl:value-of select="substring-before(Created,'T')" />
  </td>
  <td style="padding: 5px 5px 5px 15px" width="150" nowrap="false" >
   <a>
  <xsl:attribute name="href">
		<xsl:value-of select="_LinkToAttachment"/>
		<IMG style="border-style: none" alt="" src="GetIcon(_LinkToAttachment)" /> 
</a>
	


</td>
</tr>
</table>
</xsl:template>
  </xsl:stylesheet>
ASKER CERTIFIED SOLUTION
Avatar of sharepoint_new
sharepoint_new

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers