[thelist] Clever way to mix Javascript and VBScript

James Aylard evolt at pixelwright.com
Fri Nov 7 11:33:19 CST 2003


Rob Smith wrote:

> I have a form and when a user enters an ID number, the field right
> next to it shows the name associated to the ID number. Basically, or
> functionally, when the field has changed or OnBlur, the javascript
> would go match that entry to a possible pre-known set of values and
> spit the corresponding name to the field next to it.

    Simple enough.

> :-\ Do you think I could use VBscript to call a known set of values,
> then write the code that would write the corresponding JavaScript
> function. Then in my field that has the OnChange or OnBlur function,
> call that function with "this" as an argument and then have that
> function reset the next field to something it matched?

    I think that you need to step back and clarify what it is you want to
do. First, by talking about using VBScript, are you really asking about
using ASP? Please remember: there is nothing inherently "server-side" about
VBScript -- you can use it client-side in IE. And ASP does not require the
use of VBScript -- in classic ASP, you can use JavaScript server-side, as
well. So, if you mean ASP, be sure not to confuse it with VBScript.
    Otherwise, if you don't mean ASP, I have no idea why you are wanting to
mix VBScript and JavaScript. It can be done, but would be of no benefit to
you in this case, as far as I can see.

> The only problem I have with this is that my array could potentially
> be 20,000 elements long. Doing a client side search (javascript case
> statement), might be taxing on users computers.

    Don't pass back 20,000 values in an array. Do your winnowing on the
server, and pass back only the value that you want. You can either do this
the old-fashioned way, by submitting your form to the server and having it
look-up the value and rewrite the page with the name inserted into the
proper field; or you can use a hidden iframe to do a "stealth" look-up, then
use ASP to return a client-side script to the iframe that will in turn
update the name field. I have done this with IE, and simply loading a page
with a script into the iframe will cause it to execute; I don't know whether
other browsers behave this way.

James Aylard



More information about the thelist mailing list