Solved

VBScript variable in HTML IMG tag

Posted on 2010-09-03
6
1,351 Views
Last Modified: 2012-05-10
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?
0
Comment
Question by:MWGainesJR
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:spinzr0
ID: 33601730
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>
0
 
LVL 13

Author Comment

by:MWGainesJR
ID: 33602065
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.
0
 
LVL 8

Expert Comment

by:spinzr0
ID: 33603282
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")
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Accepted Solution

by:
Daz_1234 earned 500 total points
ID: 33609897
If you do not want to use ASP, you can use innerHTML to replace text inside tags in the body.

Below is a clumsy example ;o)

Hope this helps,
Daz.

<html>

<head>





<SCRIPT LANGUAGE="VBScript">



Sub LoadImageSource

    ext = replace(right("C:\madeup\path\document.doc",4),".","")

    imgsource.innerHTML = "<img src=""{FILES_DIR}/template/powerview/matter/DocIcons/" & ext & ".jpg"" height=20>"

End Sub



</SCRIPT>





</head>

<body onload="LoadImageSource">







This is the image:<br />

<span id="imgsource"></span>



</body>

</html>

Open in new window

0
 
LVL 13

Author Comment

by:MWGainesJR
ID: 33612198
I'll try the innerHTML and get back.
0
 
LVL 13

Author Closing Comment

by:MWGainesJR
ID: 33794318
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now