• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2858
  • Last Modified:

create dynamic dropdown in HTA with VBSCRIPT

hi,
    i am trying to populate a drop down in a HTA with VBScript.   I am lost on how to pass the values from the script to the SELECT in HTML.  i would appreciate any help with passing the values to the HTML dropdown

thanks

 
<html>
<head>
<title>create</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Create Accounts"
	 Borderstyle="raised"
	 Border="thin"
	 ICON="Globe.ico" 
     SCROLL="yes"
	 SYSMENU="yes"
	 VERSION="1.4"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="maximize"
	 

>

<script LANGUAGE="VBScript">

On Error Resume Next  

sub populatename()

Dim fso, folder, files, NewsFile,sFolder    
Set fso = CreateObject("Scripting.FileSystemObject")  
sFolder = "\\server\share"
If sFolder = "" Then      
Wscript.Echo "Path Does Not Exist"      
Wscript.Quit  
End If  
Set folder = fso.GetFolder(sFolder)  
Set files = folder.Files    
For each folderIdx In files    
msgbox folderIdx.Name
Next 

End Sub
 
</script>


</HEAD>


<BODY>
<B><FONT color=#107FAC>User/Group Location:<TD><select NAME=OULocation
  <option value="">
<option value="nill">-- Select Location --
<option value="city1">city1
<option value="city2">city2
<FORM NAME="Create">
 /FORM>

</BODY>



</HTML>

Open in new window


0
supportAB
Asked:
supportAB
  • 3
  • 2
1 Solution
 
RobSampsonCommented:
Hi, do you want something like this?

Regards,

Rob.
<html>
<head>
<title>create</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Create Accounts"
	 Borderstyle="raised"
	 Border="thin"
	 ICON="Globe.ico" 
     SCROLL="yes"
	 SYSMENU="yes"
	 VERSION="1.4"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="maximize"
>
<script LANGUAGE="VBScript">
Sub Window_OnLoad()
	Set objFSO = CreateObject("Scripting.FileSystemObject")  
	sFolder = "\\server\share"
	If sFolder = "" Then
		MsgBox "Path Does Not Exist"
	Else
		For Each objFile In objFSO.GetFolder(sFolder).Files
	        Set objNewOption = Document.CreateElement("OPTION")
	        objNewOption.Text = objFile.Name
	        objNewOption.Value = objFile.Path
	        Create.OULocation.Add(objNewOption)
		Next
	End If

End Sub
 
</script>


</HEAD>


<BODY>
<FORM NAME="Create">
	<FONT color=#107FAC>User/Group Location:</FONT>
	<select NAME=OULocation>
	<option value="nill">-- Select Location --</option>
	</select>
</FORM>
</BODY>
</HTML>

Open in new window

0
 
supportABAuthor Commented:
thanks, perfect, thank you.  one more question.  now, when i select one of the citys from the dropdown how do i set the <option value=>?

for example:
 normally it would be:
<option value="city">
<option value="city1">

how can i set the option value=

thanks


0
 
RobSampsonCommented:
Hi, the value is set by this line:
              objNewOption.Value = objFile.Path

so, in this case, the value of each option is set to the full path of each file.

Regards,

Rob.
0
 
supportABAuthor Commented:
thank you for all your help
0
 
RobSampsonCommented:
No problem. Thanks for the grade.

Regards,

Rob.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now