Link to home
Start Free TrialLog in
Avatar of supportAB
supportAB

asked on

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


Avatar of RobSampson
RobSampson
Flag of Australia image

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

Avatar of supportAB
supportAB

ASKER

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


ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you for all your help
No problem. Thanks for the grade.

Regards,

Rob.