000113.html | WebReference


((((((((((((((((( WEBREFERENCE UPDATE NEWSLETTER ))))))))))))))))) January 13, 2000


This newsletter sponsored by: X:Drive, IPrint.com and Petstore.com __________________________________________________________________


Get Your FREE Internet Hard Drive Today!

Leave your Zips, Disks, and Hard Drives at Home! X:drive Delivers FREE Anywhere-Anytime File Access. Securely share photos, store documents, and retrieve multimedia files from any web-connected computer in the world. Get Yours today at: http://www.xdrive.com/promo/FreeXforYou


Now with over 93000 subscribers!

http://www.webreference.com http://www.webreference.com/new/ http://www.webreference.com/new/submit.html New this week on WebReference.com and the Web:

1. CONTEST: Submit & Win!, New Subscribe & Win! Contest 2. FEATURED ARTICLE: Mix & Match: VBScript and JavaScript 3. HELP WANTED: Design Columnist 4. NET NEWS: * U.S. Sets Looser Encryption Export Rules * MetaCrawler Gets New Legs * Macromedia Flash Surges To Become Second Most Popular Plug-In * Tired of Waiting for the "New Domains"? Blame ICANN

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Submit & Win!, New Subscribe & Win! Contest

>Submit & Win!

Every Thursday the Update features a new article contributed by our readers through our Open Publishing Initiative. We encourage you to submit your own article ideas. Those that make the cut receive a free copy of Adobe GoLive 4.0!

This week, writer Jerry Gray shows us how to "Mix and Match", using VBScript and JavaScript together on Active Server Pages.


>New Subscribe & Win! Contest

Starting this week, a brand new giveaway! We've teamed up with SoftQuad and Ulead to give you a trio of hot Web building software: SoftQuad's HoTMetal Pro 6.0, Ulead PhotoImpact 5.0, and Ulead COOL 3D 2.5. Each week we'll draw new winners from our new subscribers - you could be next. Already a subscriber? Not a problem - just fill out the form, and you'll be automatically entered to win. And don't miss the announcement of the last 3 winners from the Macromedia giveaway in next Monday's newseltter!


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2. FEATURED ARTICLE: Mix and Match: Using VBScript to define and control JavaScript on Active Server Pages

In the course of my Web page work I often have used JavaScript and VBScript on Active Server Pages (ASP). While searching the Web for references to help solve programming problems, it is easy to find pages to give examples on using one or the other, but rarely do you see information regarding using them both together.

Using VBScript to control JavaScript can be as simple as using the VBScript to determine whether the JavaScript will be presented to the client browser at all. For instance, you may decide that unless a browser is at least compatible with Mozilla version 4, a given JavaScript function will not be written. In this example, we check the browser information sent by the client before writing our function.

<%strUA = Request.ServerVariables("HTTP_USER_AGENT") If InStr(strUA,"Mozilla/4") then%> Function fnMyNewFunction(){ document.write("This is not a test."); } <%End If%>

Those of you familiar with VBScript know that the tags <% %> mark the beginning and end of a VBScript, the contents of which are interpreted at the time the page is presented to the browser. If the client browser is not Mozilla 4 compatible, then the fnMyNewFunction is never written, and the client browser never even sees that it exists.

I recently had a more difficult challenge where I was asked to create a bar chart that displayed customer account history. The constraints were 1.) spawn a new page, and 2.) use an existing object that had already been populated with data. Since the project was written specifically for a client, I can't give you the full code listing, but I can walk you through the logic of the development process.


========================================== Q: What's blue, great to have on your desk, and FREE? A: Handy stamps - ideal for return addresses! ========================================== Get your FREE self-inking stamp from iPrint.com today! Pay just $1.85 for shipping to U.S. addresses. Offer good for new customers of iPrint.com only. Click below to start:



I decided I would populate a JavaScript array with data from the existing VB object, then use that array to determine the height of my images in my bar chart. Then using JavaScript, I would display the chart in a new window. (For more on creating new windows see "Window Spawning and Remotes" - http://webreference.com/js/column7).

First, using JavaScript, I declare the array I want to populate:

var arryTotAmt = new Array;

Then, using a VBscript For-Next loop, I populate the array with the values from my VB object. In this example, my VB object is named "PaymentHistory". It has already been created, and populated with values from my database, and has two important properties: "Count", which contains the total number of records in the object, and "Item", which is the nth instance of a record. Our PaymentHistory object contains many different fields associated with customer accounts, but for the purposes of our graph we are only interested in a property called "Charge". The Charge property of my PaymentHistory object contains the actual monthly value I want to put into my JavaScript array.

<% for i = 1 to PaymentHistory.Count%> arryTotAmt[<%=i%>]=<%=Cstr(PaymentHistory.Item(i).Charge)%>; <%next%>

Let's say the Charge value in our Payment History object is 35; at runtime the first time through the loop, the line will evaluate to:

ArryTotAmt[1] = 35;

The For-Next loop will continue to run, writing lines of JavaScript, incrementing the array counter, until PaymentHistory.Count is reached. For example, assuming the 2nd Charge item in our PaymentHistory object has a value of 18, then the 2nd time through the loop


will evaluate to:

ArryTotAmt[2] = 18;

Once my JavaScript array has been populated, I can then spawn a window and draw my graph.

Here is another example of embedding a VbScript variable in a JavaScript function. I need to pass the URL of the window that is going to be spawned, but the location is determined by which server and virtual root the page is run from. We hold that information in a variable called "baseurl". So the JavaScript line to spawn the new window looks something like this:

var remote = open("<%=baseurl%>/Scripts/graph.asp","Graph", "fullscreen=yes, location=no, menubar=yes, resizable=yes, status=no, toolbar=yes, dependent=no, scrollbars=yes");

Again note the special tags <% %> used to mark the beginning and end of our embedded VBscript variable.

To draw my simple bar chart, I now simply use my array value to determine the height of a holder image.


remote.document.write("<table border='1'><tr>");

//write the graph images

for (k=arryTotAmt.length - 1; k>0; k--){ remote.document.write("<td align=bottom align=center> <img src='../images/graph.gif' width=30 height=" + Math.round(parseFloat(arryTotAmt[k])) + " alt=" + arryTotAmt[k] + "></td>>); } remote.document.write("</tr><tr>");


The actual graph function I eventually used has a few more features, but the above code was the core of the solution. An example of the graph that was actually spawned can be found at http://www.webreference.com/art/000113bargraph.gif

So, as we have seen here, not only can VBScript be used to write standalone functions, it can be used to extend, and determine the characteristics of JavaScript.



GET AN INSTANT $10 OFF+FREE SHIPPING on ANY order of $20 or more @ Petstore.com! Start the New Year off right with instant cash discounts + FREE SHIPPING on your pet products and supplies. Offer expires 1/31/2000. http://www.petstore.com/promo/2000q1/aem72


Author Jerry Gray works on the Internet Application Development Team at Consumers Energy in Jackson, MI. Jerry is married, with two daughters, and holds a BS in CIS/Mgt. and a MS in Admin. Science. When not writing code, Jerry says that you can find him "playing Multi-Player BattleTech or Legends of Kesmai at Gamestorm. ;-)"

Contact Jerry at: grgray@cmsenergy.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3. HELP WANTED: Design Columnist

The contenders are out of the gate, but the race isn't over yet! Webreference.com is looking for a new design columnist - could you be the one to fill the voluminous shoes of our design columnist Dmitry Kirsanov? Only serious contenders need apply. You should have top-notch writing and design skills, and be dependable and timely.

For more information, check out the writer guidelines at: http://www.webreference.com/writers.html Or contact us directly: ecook@internet.com

Don't forget to check out the archives of Dmitry's Design Lab: http://www.webreference.com/dlab/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4. NET NEWS: U.S. Sets Looser Encryption Export Rules, MetaCrawler Gets New Legs, Macromedia Flash Surges To Become Second Most Popular Plug-In, Tired of Waiting for the "New Domains"? Blame ICANN

>U.S. Sets Looser Encryption Export Rules

U.S. Companies selling everything from e-mail software to computer networking equipment will be able to export products containing far more powerful encryption security features starting on Friday under new rules released by the Clinton administration. http://dailynews.yahoo.com/h/nm/20000113/tc/tech_encryption_3.html Yahoo.com, 000113

>MetaCrawler Gets New Legs

Looking to regain its status as a leading search engine, Go2Net's Metacrawler search engine relaunched Thursday with a new interface, customization tools and expanded categories. http://www.internetnews.com/bus-news/article/0,1087,3_282391,00.html InternetNews.com, 000113

>Macromedia Flash Surges To Become Second Most Popular Plug-In

Web audience analysts WebSiteStory reported that the installed base of Macromedia's Flash application has risen nearly 23 percentage points in the past year and now ranks as the No. 2 plug-in. http://www.internetwire.com/technews/tn/01986342.dsl InternetWire.com, 000112

>Tired of Waiting for the "New Domains"? Blame ICANN

Are we getting dealt a fair hand by Internet Corp. for Assigned Names and Numbers in regards to new top-level domains that can compete with NSI's dot com? Not according to Internet analyst Milton Mueller, who says ICANN's creation and the ensuing Internet domain name war has delayed the introduction of the new top-level domains. http://www.internetnews.com/wd-news/article/0,1087,10_279641,00.html InternetNews.com, 000111

That's it for this week, see you next time.

Andrew King Managing Editor, WebReference.com update@webreference.com

Eric Cook Assistant Editor, WebReference.com ecook@internet.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sponsoring the WebReference Update is a cost effective way to reach thousands of qualified buyers. Just ask Frank Fazio, Director of Inside Sales to find out how. Contact: (203)662-2997 or mailto:ffazio@internet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Also on Internet.com .... http://www.Internet.com

Internet News Channel http://www.internet.com/sections/news.html Internet Stocks/VC Channel http://www.internet.com/sections/stocks.html Internet Technology Channel http://www.internet.com/sections/it.html Windows Internet Technology Channel http://www.internet.com/sections/win.html Linux/Open Source Channel http://www.internet.com/sections/linux.html Web Developer Channel http://www.internet.com/sections/webdev.html E-Commerce/Marketing http://www.internet.com/sections/marketing.html ISP Resources Channel http://www.internet.com/sections/isp.html Download Channel http://www.internet.com/sections/downloads.html Internet Resources Channel http://www.internet.com/sections/resources.html Internet List Channel http://www.internet.com/sections/lists.html International Channel http://www.internet.com/sections/international.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To SUBSCRIBE to the WEBREFERENCE-UPDATE: 1. subscribe@webreference.com or webreference-update-text-on@list4.internet.com

To UN-SUBSCRIBE from WEBREFERENCE-UPDATE do NOT reply to this message, instead: 1. unsubscribe@webreference.com or webreference-update-text-off@list4.internet.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Copyright (c) 2000 Jupitermedia Corp. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WEBREFERENCE-UPDATE is powered by Lyris(R) http://www.lyris.com