Solved

VBScript variable in HTML IMG tag

Posted on 2010-09-03
6
1,454 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

622 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