Link to home
Start Free TrialLog in
Avatar of MWGainesJR
MWGainesJRFlag for United States of America

asked on

VBScript variable in HTML IMG tag

I have this VBscript:

<SCRIPT LANGUAGE="VBScript">
ext = replace(right("{DOC:FileName}",4),".","")
</SCRIPT>

I need to place ext as the file name in:

<img src="{FILES_DIR}/template/powerview/matter/DocIcons/(place ext here).jpg" height=20>

What is the proper way to do this?
Avatar of spinzr0
spinzr0
Flag of United States of America image

You're better off getting the extension using the GetExtensionName from file system object:

sExt = CreateObject("Scripting.FileSystemObject").GetExtensionName("{DOC:FileName}")

For the placement inline, you can just use ASP to do inline.  Here is an example:

<html>
<head>
<%
sub vbproc(num1,num2)
response.write(num1*num2)
end sub
%>
</head>
<body>

<p>Result: <%call vbproc(3,4)%></p>

</body>
</html>
Avatar of MWGainesJR

ASKER

Will the FSO method return the extension even if the filepath and name stored in DOC:Filename isn't on the same machine?
Doc:Filename is simply a field with a string.....may not be accessible from current machine.
FSO will accept a file or a string as an arg so it should work.  If you caled this it would work so it should be the same:

sExt = CreateObject("Scripting.FileSystemObject").GetExtensionName("c:\test.vbs")
ASKER CERTIFIED SOLUTION
Avatar of Darren Collins
Darren Collins
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'll try the innerHTML and get back.
Thanks