[thelist] Clever way to mix Javascript and VBScript
Simon Perry
simon.perry at si-designs.co.uk
Fri Nov 7 11:33:42 CST 2003
Rob Smith wrote:
>Hello,
>
>I know some of you may be saying, "What are you doing mixing those two
>languages?! They don't belong together." Yeah I know but here's what I want
>to happen:
>
>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.
>
>:-\ 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?
>
>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.
>
>Your two cents if you please?
>
>Rob Smith
>
>
I think that you would be better served using a hash [1] rather than an
array to store your data. To access the name you would then use the id
as the key. Given the size of your data it might be an idea to get users
to chose a range where their id appears. You can the limit the client
side hash to X,000 elements.
Simon
[1] http://www.crockford.com/javascript/survey.html
More information about the thelist
mailing list