×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Populate values in the 2nd drop down based on the values selected in the first drop down

Populate values in the 2nd drop down based on the values selected in the first drop down

Populate values in the 2nd drop down based on the values selected in the first drop down

(OP)
Hi,

I'm a beginer in vbscript. Can you please let me know how to populate values in the second combo box based on the value selected in the first combo box?

Example:
If I select fruits category in the first combo box then the second combo box should populate the values like Apple, banana, orange, grape and etc like wise the values should be populated based on the category that is selected in the first combo box.

Please let me know.

Thanks!

RE: Populate values in the 2nd drop down based on the values selected in the first drop down

What code do you have and where are you stuck?

RE: Populate values in the 2nd drop down based on the values selected in the first drop down

Since combo boxes are not native to VBScript I am assuming you are working on an HTA file?

Check out the Microsoft HTA tool.

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: Populate values in the 2nd drop down based on the values selected in the first drop down

(OP)
Thnaks guitarzan and Mark for your responses.

Guitarzan, Here is the code that I have.Please let me know how to populate the items list based on the category that is selected

==============================================================
<html>
<head>
<title>Category</title>

<HTA:APPLICATION
ID="objHTA"
APPLICATIONNAME="category"
SCROLL="yes"
SINGLEINSTANCE="yes"
>
</head>

<SCRIPT Language="VBScript">

Sub Window_Onload
LoadDropDown
End Sub

Sub LoadDropDown

ClearListBox
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFile = objFS.OpenTextFile("categories.txt")
strcatr = objFile.ReadAll
objFile.Close
arrcatr = Split(strcatr, vbNewLine)
For Each strNumber in arrcatr
Set objOption = Document.createElement("OPTION")
objOption.Text = strNumber
objOption.Value = strNumber
category.Add(objOption)
Next

End Sub

Sub ClearListbox
For Each objOption in category.Options
objOption.RemoveNode
Next
End Sub

</SCRIPT>

<body>
<select onActivate=LoadDropDown name="category">
</select>

<select name="Items">
</select>
</body>
</html>

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close