none
VBScript in HTA error. RRS feed

  • Question

  • Hi all,

    I am working on a HTA script for my SCCM environment. The way it works is, you start up the Network boot. The HTA script pops up. You select the country, profile and location. And based on that, the deployment will choose the right steps. My problem is, I succesfully created two Task Sequence variables with associated dropdownlists. But now I am trying to get the 3rd one (Location) to work. The HTA script shows up succesfully, but when I hit the submit button with my choices from the dropdownlist, I get this error:

    "Object doesn't support this property or method:
    window.Location.selectedIndex"

    My code:

    <HEAD>
    	<TITLE>Task Sequence Menu</TITLE>
    	<HTA:APPLICATION APPLICATIONNAME="Task Sequence Menu" SCROLL="no" SINGLEINSTANCE="yes" WINDOWSTATE="normal" SYSMENU="no" CAPTION="no" BORDER="none" INNERBORDER="no">
    	<link rel="stylesheet" href="css/fonts.css" type="text/css" charset="utf-8" />
    	<SCRIPT LANGUAGE="VBScript">
    	'Resize window
    	Sub Window_onLoad
            window.resizeTo 500,225
    		window.moveTo (screen.width - 500)/2, (screen.height - 225)/2
    	End Sub 
    
    	'Hides Task Sequence Progress
    	Set ProgressUI = CreateObject("Microsoft.SMS.TSProgressUI")
    	ProgressUI.CloseProgressDialog
    
    	Sub ButtonSkip
    		window.Close
    	End Sub
    	
    	Sub ButtonFinish
    		Dim strCountry
    		Dim strLocation
    		Dim strMode
        
    		Set TSEnv = CreateObject("Microsoft.SMS.TSEnvironment")
    	
    		oCountryElements = Window.Country.selectedIndex
    		strCountry = Window.Country.options(oCountryElements).Text
       
    		'Set select DropdownList
    		Select Case strCountry
    			Case "Country1"
    			TSEnv("Country") = "CO"
    			Case "Country2"
    			TSEnv("Country") = "CT"			
    		End Select
    		
    		oLocationElements = Window.Location.selectedIndex
    		strLocation = Window.Location.options(oLocationElements).Text
       
    		'Set select DropdownList
    		Select Case strLocation
    			Case "Location1"
    			TSEnv("Location") = "3343"
    			Case "Location2"
    			TSEnv("Location") = "3344"			
    		End Select
    
    		TSEnv("Mode") = "WIPENLOAD"
    
    		'Closes window
    		window.Close	
    	End Sub
    	</SCRIPT>
    </HEAD>
    
    <BODY>
    	<div id="container">
    	<div id="header">
    		<img src="css/fact.png">
    	</div>
    	<div id="content">
    		<p>If you'd like to keep the current configuration/profile and hostname, click <span style="color: #ff6600; font-weight: bold">skip</span>. Otherwise, make the apropriate selections below and click <span style="color: #ff6600; font-weight: bold">generate</span>.</p>
    		<p>
    		<SELECT NAME="Country">
    			<OPTION>Country1</OPTION>
    			<OPTION selected="yes">Country2</OPTION>
    		</SELECT>
    		<SELECT NAME="Location">
    			<OPTION>Location1</OPTION>
    			<OPTION selected="yes">Location2</OPTION>
    		</SELECT>
    		</p>
    		<br />
    		<p>
    		<INPUT id=skipbutton type="button" value="skip" name="skip_button" onClick="ButtonSkip"> <INPUT id=runbutton type="button" value="generate" name="run_button" onClick="ButtonFinish"></span>
    		</p>
    	</div>
    	</div>
    </BODY>




    • Edited by TIOOWY Tuesday, February 26, 2019 9:40 AM
    Tuesday, February 26, 2019 9:35 AM

Answers

  • Window already has a property called “Location”. Did you try a different name for your <SELECT> element?

    • Marked as answer by TIOOWY Tuesday, February 26, 2019 11:34 AM
    Tuesday, February 26, 2019 10:52 AM

All replies

  • Window already has a property called “Location”. Did you try a different name for your <SELECT> element?

    • Marked as answer by TIOOWY Tuesday, February 26, 2019 11:34 AM
    Tuesday, February 26, 2019 10:52 AM
  • In the meantime I tried this. This was indeed what solved the error. Still thanks :D.
    • Edited by TIOOWY Tuesday, February 26, 2019 11:36 AM
    Tuesday, February 26, 2019 11:36 AM