VBScript to Javascript

Posted on 2011-05-13
Last Modified: 2012-08-13
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

Question by:Chris Bottomley
    LVL 9

    Accepted Solution

    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
    LVL 59

    Author Closing Comment

    by:Chris Bottomley
    Great thank you, full completion was achieved in the related thread.

    Anyone looking here for clues then I suggest you look to for the complete picture.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
    Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
    Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
    This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now