Solved

VBScript variable in HTML IMG tag

Posted on 2010-09-03
6
1,375 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 13

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to make a moving character 3 57
Input box width 6 26
VB Script: create txt file with DateStamp and IP Adress 6 23
Batch file or script with password 22 43
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
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…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

770 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