472,353 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Convert javascript to vb script?

Hi,

This javascript creates a table that has a header and side column that
do not move while scrolling through the table. I need to convert this
to vb script. Can anybody help, or do you have code in vb (asp) that
would do the same thing?

<html>
<head>
<title>Scrolling Grid Demo</title>
<script type="text/javascript">
function Grid(name, data)
{
// store arguments
this.name = name;
this.data = data;

var cursor = document.all ? "hand" : "pointer";

// persist object for later use.
window[name] = this;

// initialize internal properties.
this.xOffset = 0;
this.yOffset = 0;

// render table
var aStr = new Array;
aStr.push('<table border=1 cellpadding=0 cellspacing=0 id="' +
this.name + '">');

// column header row
aStr.push('<tr>');
aStr.push('<td>&nbsp;</td>');
for ( var j = 0; j < this.data.nCol; j++ )
{
aStr.push('<th width=' + this.data.nCellWidth + '><span>' +
this.data.colHeaders[j] + '</span></th>');
}
aStr.push('<td width=20>&nbsp;</td>');
aStr.push('</tr>');

// data rows
for ( var i = 0; i < this.data.nRow; i++ )
{
aStr.push('<tr>');
aStr.push('<th valign=top width=' + this.data.nCellWidth + '><span>'
+ this.data.rowHeaders[i] + '</span></th>');
for ( j = 0; j < this.data.nCol; j++ )
aStr.push('<td><span style="overflow:hidden;width:' +
this.data.nCellWidth + 'px;height:' + this.data.nCellHeight + 'px;
text-align:center;">' + this.data.values[i][j] + '</span></td>');

// add the vertical scroll bar
if ( i == 0 )
{
aStr.push('<td rowspan=' + this.data.nRow + ' valign=top>');
aStr.push('<div style="position:relative;height:' + nHeight +
'px;width:20px;">');

// add the scroll indicator
var nHeight = this.data.nRow * this.data.nCellHeight +
(this.data.nRow-1) * 2;
var nStartHeight = 1;
var nBarHeight = Math.floor(nHeight * this.data.nRow /
this.data.rowHeaders.length);
var nEndHeight = nHeight - nStartHeight - nBarHeight;
aStr.push('<div style="position:absolute;height=120px;">');
aStr.push('<table width=20 height=' + nHeight + ' border=0
cellpadding=0 cellspacing=0>');
aStr.push('<tr><td height=1><div></div></td></tr>');
aStr.push('<tr><td height=' + nBarHeight + ' bgcolor="#33cc33"
height=20><div></div></td></tr>');
aStr.push('<tr><td height=' + nEndHeight +
'><div></div></td></tr>');
aStr.push('</table>');
aStr.push('</div>');

// add the scroll buttons
aStr.push('<div style="position:absolute;height=' + nHeight +
'px;width=20px;">');
aStr.push('<table width=20 height=' + nHeight + ' border=0
cellpadding=0 cellspacing=0>');
aStr.push('<tr><td width=' + nHeight/2 + ' valign=top
align=center><div style="cursor:' + cursor + ';" onclick="window.' +
this.name + '.scroll(0,-1);">^</div></td></tr>');
aStr.push('<tr><td width=' + nHeight/2 + ' valign=bottom
align=center><div style="cursor:' + cursor + ';" onclick="window.' +
this.name + '.scroll(0,1);">v</div></td></tr>');
aStr.push('</table>');
aStr.push('</div>');

aStr.push('</div>');
aStr.push('</td>');
}

aStr.push('</tr>');
}

// add the horizontal scroll bar
aStr.push('<tr>');
aStr.push('<td>&nbsp;</td>');
aStr.push('<td colspan=' + this.data.nCol + '>');
aStr.push('<div style="position:relative;width=' + nWidth +
'px;height=20px;">');

// the scroll indicator part
var nWidth = this.data.nCol * this.data.nCellWidth +
(this.data.nCol-1) * 2;
var nStartWidth = 1;
var nBarWidth = Math.floor(nWidth * this.data.nCol /
this.data.colHeaders.length);
var nEndWidth = nWidth - nStartWidth - nBarWidth;
aStr.push('<div style="position:absolute;width=' + nWidth +
'px;left:0px;top:0px">');
aStr.push('<table width=' + nWidth + ' border=0 cellpadding=0
cellspacing=0>');
aStr.push('<tr>');
aStr.push('<td width=1><div></div></td>');
aStr.push('<td width=' + nBarWidth + ' bgcolor="#33cc33"
height=20><div></div></td>');
aStr.push('<td width=' + nEndWidth + '><div></div></td>');
aStr.push('</tr>');
aStr.push('</table>');
aStr.push('</div>');

// the scroll buttons
aStr.push('<div style="position:absolute;width=' + nWidth +
'px;;left:0px;top:0px">');
aStr.push('<table width=' + nWidth + ' border=0 cellpadding=0
cellspacing=0>');
aStr.push('<tr>');
aStr.push('<td width=' + nWidth/2 + ' align=left><div style="cursor:'
+ cursor + ';width:20px;" onclick="window.' + this.name +
'.scroll(-1,0);">&lt;</div></td>');
aStr.push('<td width=' + nWidth/2 + ' align=right><div
style="cursor:' + cursor + ';width:20px;" onclick="window.' +
this.name + '.scroll(1,0);">&gt;</div></td>');
aStr.push('</tr>');
aStr.push('</table>');
aStr.push('</div>');

aStr.push('&nbsp;');

aStr.push('</div>');
aStr.push('</td>');
aStr.push('<td>&nbsp;</td>');
aStr.push('</tr>');

// finally close off the table
aStr.push('</table>');

// write HTML to document.
document.write(aStr.join(''));
}

// locate all spans and control points
Grid.prototype.init = function()
{
// if already initialized, return
if ( this.oTable ) return;

this.oTable = document.getElementById(this.name);

// get all <span> elements within the table
var aSpan = this.oTable.getElementsByTagName('span');
var n = 0;
// the first few are all column headers
this.aColSpan = new Array;
for ( var j = 0; j < this.data.nCol; j++ )
this.aColSpan.push(aSpan[n++]);

// the remainder are row headers and cells
this.aRowSpan = new Array;
this.aCellSpan = new Array;
for ( var i = 0; i < this.data.nRow; i++ )
{
this.aRowSpan.push(aSpan[n++]);

this.aCellSpan.push(new Array());
for ( j = 0; j < this.data.nCol; j++ )
this.aCellSpan[i].push(aSpan[n++]);
}

// get all the <div> elements
var aDiv = this.oTable.getElementsByTagName('div');

// the vertical scroll is in aDiv[2]
this.aVerticalTD = aDiv[1].getElementsByTagName('td');

// the horizontal scroll is in aDiv[10]
this.aHorizontalTD = aDiv[9].getElementsByTagName('td');
}

// fill all the column/row headers and cell values
// and adjust the scroll bars
Grid.prototype.fill = function()
{
this.init();

// headers
for ( var j = 0; j < this.data.nCol; j++ )
this.aColSpan[j].innerHTML = this.data.colHeaders[j + this.xOffset];
for ( var i = 0; i < this.data.nRow; i++ )
this.aRowSpan[i].innerHTML = this.data.rowHeaders[i + this.yOffset];

// values
for ( i = 0; i < this.data.nRow; i++ )
for ( j = 0; j < this.data.nCol; j++ )
this.aCellSpan[i][j].innerHTML = this.data.values[i +
this.yOffset][j + this.xOffset];

// scroll bars
var nHeight = this.data.nRow * this.data.nCellHeight +
(this.data.nRow-1) * 2;
var nStartHeight = Math.floor(nHeight * this.yOffset /
this.data.rowHeaders.length);
if ( nStartHeight == 0 ) nStartHeight++;
var nBarHeight = Math.floor(nHeight * this.data.nRow /
this.data.rowHeaders.length);
var nEndHeight = nHeight - nStartHeight - nBarHeight;
if ( nEndHeight == 0 ) nStartHeight--, nEndHeight++;

this.aVerticalTD[0].height = nStartHeight;
this.aVerticalTD[1].height = nBarHeight;
this.aVerticalTD[2].height = nEndHeight;

var nWidth = this.data.nCol * this.data.nCellWidth +
(this.data.nCol-1) * 2;
var nStartWidth = Math.floor(nWidth * this.xOffset /
this.data.colHeaders.length);
if ( nStartWidth == 0 ) nStartWidth++;
var nBarWidth = Math.floor(nWidth * this.data.nCol /
this.data.colHeaders.length);
var nEndWidth = nWidth - nStartWidth - nBarWidth;
if ( nEndWidth == 0 ) nEndWidth++, nStartWidth--;

this.aHorizontalTD[0].width = nStartWidth;
this.aHorizontalTD[1].width = nBarWidth;
this.aHorizontalTD[2].width = nEndWidth;
}

Grid.prototype.scroll = function(x,y)
{
this.xOffset += x;
if ( this.xOffset < 0 ) this.xOffset = 0;
if ( this.xOffset > this.data.colHeaders.length - this.data.nCol )
this.xOffset = this.data.colHeaders.length - this.data.nCol;

this.yOffset += y;
if ( this.yOffset < 0 ) this.yOffset = 0;
if ( this.yOffset > this.data.rowHeaders.length - this.data.nRow )
this.yOffset = this.data.rowHeaders.length - this.data.nRow;

this.fill();
}
</script>
</head>
<body>
ggg

<script>
var currencies = ["ARS","ATS","AUD","BBD","BEF","BGL","BMD","BRL","B SD","CAD",
"CHF","CLP","CNY","CYP","CZK","DEM","DKK","DZD","E GP","ESP",
"EUR","FIM","FJD","FRF","GBP","GRD","HKD","HUF","I DR","IEP",
"ILS","INR","ISK","ITL","JMD","JOD","JPY","KRW","L BP","LUF",
"MXN","MYR","NLG","NOK","NZD","PHP","PKR","PLN","P TE","ROL",
"RUR","SAR","SDD","SEK","SGD","SKK","THB","TRL","T TD","TWD",
"USD","VEB","XAG","XAU","XCD","XDR","XPD","XPT","Z AR","ZMK"];
var data =
{
nCol:6,
nRow:10,
nCellWidth:70,
nCellHeight:20
};
data.colHeaders = currencies;
data.rowHeaders = currencies;
data.values = new Array();
for ( var i = 0; i < currencies.length; i++ )
{
data.values.push(new Array());
for ( var j = 0; j < currencies.length; j++ )
{
if ( i == j )
data.values[i].push('-');
else
data.values[i].push(Math.round(10000*Math.random() /
Math.random())/10000);
}
}
new Grid('theGrid', data);
</script>
Full scrolling grid example.
NB: The values in this table bear no relation to any currency, real
or imaginary.
</body>
</html>
Jul 23 '05 #1
4 9535
In article <c8**************************@posting.google.com >,
d_*******@hotmail.com enlightened us with...
Hi,

This javascript creates a table that has a header and side column that
do not move while scrolling through the table. I need to convert this
to vb script.


Why? ASP can use javascript (JScript) if you wanted it to run on the
server. However, a lot of the stuff here uses client-side only things,
like the height of page elements, which will not be available on the
server. So, you must want it for client-side use. Converting it to
vbscript for client-side use will work only in IE.

What are you really wanting to do? Create something on the server, or
the client?

ASP, which runs on the server, creates html pages on the fly. It knows
nothing of the client (usually a browser). It simply sends a response to
whatever user agent sent it a request.

--
--
~kaeli~
If at first you don't succeed, skydiving is not for you.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
"D Newsham" <d_*******@hotmail.com> wrote in message
news:c8**************************@posting.google.c om...
Hi,

This javascript creates a table that has a header and side column that
do not move while scrolling through the table. I need to convert this
to vb script. Can anybody help, or do you have code in vb (asp) that
would do the same thing?


[snip]

You did a multipost (separate copies to separate NGs) instead of a crosspost
(one copy to more than one NG).

Please do not multipost!
Jul 23 '05 #3
I apologize for the multipost. I got an error in Google the first
time I posted this, which said it hadn't been posted. Since the posts
don't come up for several hours, I did not realize it had already
posted.
Jul 23 '05 #4
"D Newsham" <d_*******@hotmail.com> wrote in message
news:c8**************************@posting.google.c om...
I apologize for the multipost. I got an error in Google the first
time I posted this, which said it hadn't been posted. Since the posts
don't come up for several hours, I did not realize it had already
posted.


Multi-post means you the same message in different newsgroups, not the same
message in one newsgroup at different times.

You posted this same message in the "microsoft.public.scripting.vbscript"
newsgroup (where I offered a partial solution).
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: noah.coffey | last post by:
Hello, I'm wanting to do something and I'm not sure if it's possible (I'd sure like it to be). I'm using a neat service called FeedSweep to...
6
by: nate | last post by:
Hello, Does anyone know where I can find an ASP server side script written in JavaScript to parse text fields from a form method='POST' using...
5
by: Robin Johnson | last post by:
Hi, I've written an engine in Javascript for running text adventure games on a web page: ...
3
by: geotso | last post by:
Hi I use the following script in order to show/hide a section, and at the same time to change a companion .gif with another: function...
1
by: sathyan8294 | last post by:
what is websites for convert javascript to vbscript?
7
by: maria80e | last post by:
Is it possible to convert javascript(.js) file as exe or dll? Regards, Maria prabudass E
2
by: murugavelmsc | last post by:
Hi, i have a javascript code. I want to convert into VBscript. pls help me Javascript Code:
5
by: rmartine28 | last post by:
i am looking to post something in myspace profile that is java but their system doesn't allow java script, can any one tell me how to convert a...
0
by: Abdul Gbadamosi | last post by:
how can i pass an argument to a javascript script tag in html from a python file?
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.