Results 1 to 2 of 2
  1. #1

    Javascript & VBScript

    I have a piece of VBScript which generates an array from a database, containing 4 fields. I use another bit of VBScript to fill a dropdown list. The problem is that when I select an item from the list, I want to assign values to three hidden fields based on the corresponding array elements. I can't get the right syntax to add to the 'onChange' command.
    e.g. array contains (1,A,1A,A1/2,B,2B,B2/3,C,3C,C3) If I choose the 2nd item from the dropdown list (1,2,3), then H1, H2 & H3 will contain B, 2B & B2 respectively.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 93 Times in 89 Posts

    Re: Javascript & VBScript

    Being trained as an economist, I'm going to assume that you have the value 1, 2, or 3 from your drown-down control. Let's call that value varSelection, which we hope is a Variant of sub-type integer or long. (If it is a double or single, you might want to convert it to CInt before doing the below.)

    You could write something like this:

    H1 = myArray((varSelection * 3) - 2)
    H2 = myarray((varSelection * 3) - 1)
    H3 = myArray(varSelection * 3)

    This should fill your fields with the right values.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts