computers: javascript vs. VBscript vs ASP

Hey, I could use some help from some coding pros. I’ve walked into a bad web project, I think its about to get worse so I could use some advice. I know someone out there is good at this stuff…

I’ve been working with dynamic websites with PHP/MySQL/Apache for a while, and I got hooked into trying some of their dynamic website tricks on someone’s Microsoft IIS server. They want me to build some simple dynamic pages that can get data from a MS Access database and build a page using ASP scripts. I found some really good tools in DreamWeaver UltraDev for ASP scripts, it seems to like VBScript and ASP with ADO.

However, at the last minute, the client demanded I toss in some popup menus in Javascript. It appears to me that you can only have one language per page, either javascript or VBScript. Can I have scripts from both languages on one page? I don’t quite understand the relationship between Javascript/VBScript and ASP. Fortunately (or perhaps unfortunately) UltraDev insulates me from some of this, and does some of it automatically, but I think I better figure this out.

Just to be a total pain in the ass, the client also gave me a cgi script that accesses some server in god-knows-where to download the corporation’s stock price, and spit it out in text. It looks like I’d have to wrap it in a VBScript if I want it to output on an ASP page. I’m confused. Hell, I’m burned out on this. Give me PHP/MySQL and a Mac anyday.

I’m in over my head hear, so don’t take anything I say as gospel.

I think it’s possible to use more than one scripting language in a document just by using the ‘language’ attribute of the ‘script’ tag.

<script language=‘VBscript’>
… VBScript code here …
</script>
<script language=‘Javascript’>
… Javascript code here …
</script>

As far as the relationship between the two: I don’t think there is one. But, as I said, I’m not an expert.

>> As far as the relationship between the two: I don’t think there is one

::whispering:: (You don’t know?! They’ve been seeing each other for a couple of months now. But don’t tell anyone I told you.)

Yeah, BlackKnight, that’s what I figure I can do, I’ll just try putting both scripts in and see what they do. The trick is hiding it from the user who has to modify these pages. Fortunately, UltraDev has some nice features to hide the scripts. I could even make them external files, so they don’t fiddle with em.
I got these stupid Javascript/DHTML menubars up and running ok. Now I just have to get the database scripts up accessing some ADO with VBScript. Why oh why did I agree to work on Microsoft servers?

You can have both JavaScript and VBScript in ASP pages, including inline.

For example:


<HTML>

<%

Dim UserName

UserName = Session("UserName")

%>

<BODY>

<FORM NAME="MyForm" METHOD="Post" ACTION="http://www.myaddress.com">

<INPUT TYPE="Button" VALUE="Continue" onClick="user_clicked(<% Response.Write UserName %> )">

</FORM>

</BODY>

<SCRIPT LANGUAGE="JavaScript">

function user_clicked(user_name)
{
document.MyForm.action='http://www.myaddress.com?'+user_name;
document.MyForm.submit();
}
</SCRIPT>

</HTML>

By the way, you can even use one to write out the other!

For example, using server-side VBScript:


<HTML>

<%

Dim Q

Q = Chr(34)

With Response

.Write "<SCRIPT LANGUAGE=" & Q & JavaScript" & Q & >"

[...etc...]

.Write "</SCRIPT>"

End With

%>

</HTML>

In fact, you could write out your entire ASP page with server-side code.

In an application like this, you’d typically use the ASP to build the Javascript code for your dropdown.

For example, you might do something like this - (for the sake of the discussion, rsData is a recordset containing the names of some people you want to put in a drop-down menu). This is in ASP-ish pseudocode, to make it easier to read
function BuildDropdown()

do
response.write (HTML option statement, with value= rsData.Fields(“Name”) and name=dropdown)
while (Not End of Recordset)

end function

Then in your html block at the end, you would have something like this:

<SELECT name=dropdown>
<% =BuildDropDown() %>
</SELECT>

Offhand, I can’t remember if my syntax is exactly correct, but you get the idea - you use the ASP to build your recordsets, then the ASP page builds the client page, including the options for all the dropdowns, etc. This is the standard method for working in ASP.

What language is the CGI script in? You might be better off to simply write the functionality as part of your ASP page, or build a COM object to do the work. CGI is a lousy technology, because it’s out of process and eats resources.