?
Solved

create dynamic dropdown in HTA with VBSCRIPT

Posted on 2011-03-09
5
Medium Priority
?
2,717 Views
Last Modified: 2012-06-27
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
Comment
Question by:supportAB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 35088904
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
 

Author Comment

by:supportAB
ID: 35089103
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
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 35089187
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
 

Author Closing Comment

by:supportAB
ID: 35094051
thank you for all your help
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 35099545
No problem. Thanks for the grade.

Regards,

Rob.
0

Featured Post

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question