Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

tulsantide

Technical User
Jun 1, 2015
21
US
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!
 
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
Work SMARTER not HARDER.
 
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>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top