Solved

VBScript variable in HTML IMG tag

Posted on 2010-09-03
6
1,328 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 12

Accepted Solution

by:
Daz_1234 earned 500 total points
Comment Utility
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
Comment Utility
I'll try the innerHTML and get back.
0
 
LVL 13

Author Closing Comment

by:MWGainesJR
Comment Utility
Thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

772 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

10 Experts available now in Live!

Get 1:1 Help Now