Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBScript variable in HTML IMG tag

Posted on 2010-09-03
6
Medium Priority
?
1,546 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Accepted Solution

by:
Daz_1234 earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

877 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