Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript converted to VBScript

Status
Not open for further replies.

TommyB44

Technical User
Jun 16, 2005
76
GB
Hi, All

I'm looking to convert this javascript to ASP (VBScript) does anyone know the best way to do this?

this is the Javascript code that works fine for me, but i'd sooner have ASP(VBscript) do the job. I
still need it to write to the div tag only

the list in a js file (list.js)
Code:
var s="$o~image~data~data~data~data$f~image2~data~data~data~data";

the function

Code:
function dolist() {
    var listings = s.split("$");
    for(i=1; i<listings.length; i++){
        listing = listings[i].split("~");
        listings[i]={
            css: listing[0],
            listImage: listing[1],
            title: listing[2],
            Time: listing[3],
            age: listing[4],
            listID: listing[5]
        }
    }
   var list = document.getElementById("list");
    var txt = "<table cellSpacing=0 cellPadding=0 width='720' border=0 align=left>";
    
  for(i=1; i<listings.length; i++){
        txt += "<tr><td width=20% class="+listings[i].css+"><img src='image/"
            +listings[i].listImage+"b.jpg' height=60></td><td width=40% class="+listings[i].css+">"
            +listings[i].title+"</td><td width=15% class="+listings[i].css+">"
            +listings[i].Time+"</td><td width=15% class="+listings[i].css+">"
            +listings[i].age+"</td><td width=10% class="+listings[i].css+">"
            +listings[i].listID
            +"</td></tr>";
    }
    txt += "</table>";
    list.innerHTML = txt;
}

the html on the page

Code:
<script src="list.js"></script>

MORE HTML

<div id="list" style='width:740;height:410'>
</div>


MORE HTML

i was thinking of putting the list.js in a text file ($o~image~data~data~data~data$f~image2~data~data~data~data) and
using fs.OpenTextFile() to get the text then split and write it with some more asp like the javascript does, If i was to
give this alot of thought i'd probably stay with the javascript version, but i wouldn't learn new things if i did that.

Thanks For Reading
 
FYI, you can intermix javascript with ASP without any problems...

-DNG
 
yeah, thats what i'm doing now, but i'd still like to use an ASP(vbscript) version of this function.
 
something like this...below is a simple test script

dim myarray

myarray= split(s,"$")

for i=0 to uBound(myarray)

response.write myarray(i)

next

run it and see the display...should give you some idea

-DNG




 
Thanks DNG, that gives me something to work with.
 
all other modifications should be simple once you assign all the array elements to the variables you want...post back if you get any errors...

-DNG
 
yeah, i think i'll need to run the split twice one split within the other, as the start of a new <TR> is at the "$" charcater, then it's sub splits "~".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top