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

VBScript to Javascript

I have no idea how simple this is but I want to implement a VBS off a website as javascript.  Up front I am reasonably competent with VBS and a numpty with Javascript.  Basicaly the sub gathers the contents of a range of dropdowns to be subsequently passed to a VBS to process the files.

The generatefile sub is stored in and triggered in one frame, (top) and the combos are in another, (main).  Top has a form with a single button which when pressed runs generatefile to get a comma delimited list of the combo selections.

Variable files is a parameter required of the form action so can be ignored apart from the fact that on completion it is to be a comma seperated list of the drop down values.

retfilenames can I hope be ignored as it takes the dropdown contents in turn and concateneates them ... I will be asking seperately for this conversion so if you accept it takes two strings and returns the merged result of each input.

Sub GenerateFile()

	Set MainFrm = parent.document.frames("main")
	If MainFrm Is Nothing Then
		msgbox "Couldn't get frame"
		Set DocObj = MainFrm.document
		Set InObj = DocObj.getElementById("combo1")
		strFileName = InObj.value
		strfilenames = retfilenames(strfilenames, strfilename)

		Set InObj = DocObj.getElementById("combo2")
		strFileName = InObj.value
		strfilenames = retfilenames(strfilenames, strfilename)

msgbox replace(strfilenames, ",", vbcrlf)

		document.getElementById("files").value = strFileNames
	end if
End Sub

Open in new window

Chris Bottomley
Chris Bottomley
1 Solution
iGottZFrontend EngineerCommented:
function GenerateFile() {
	var MainFrm = parent.document.frames("main") || false;
	if (!MainFrm) {
		alert("Couldn't get frame");
	var DocObj = MainFrm.document;
	var InObj = DocObj.getElementById("combo1");
	strFileName = InObj.value;
	strfilenames = retfilenames(strfilenames, strfilename);
	var InObj = DocObj.getElementById("combo2");
	strFileName = InObj.value;
	strfilenames = retfilenames(strfilenames, strfilename);
	strfilenames = strfilenames.replace(/\r\n/gi, ",");
	document.getElementById("files").value = strfilenames;

Open in new window

as note: if strFileName and strfilenames are not initialized outside that function i will tell you to write var before their initialisations.

also keep in mind that variables in javascript are case sensitive
Chris BottomleyAuthor Commented:
Great thank you, full completion was achieved in the related thread.

Anyone looking here for clues then I suggest you look to http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_27036095.html for the complete picture.


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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