none
.Hta with Visual Basic Script RRS feed

  • Question

  • #I am working on an hta file to create a debug tool.
    
    #I am using Visual Basic to split a file. The file has two
    #sets of ip addresses. Ex: 10.123.12.12 and 010.123.012.012.
    
    #The one with the leading zeros is needed for a printer. 
    #The one without is used to connect to the printer via a web
    #browser. 
    
    #The visual basic script I am trying is:
    sub ShowInstructions()
                    'MsgBox "Button Pressed"
    		Set opt = document.createElement("option")
    		Set opt2 = document.createElement("option")
                    opt.Value = ""
                    opt.Text  = "Select Printer"
                    Document.getElementById("dropdown1").add opt
    		set oFSO=CreateObject("Scripting.FileSystemObject")
    		set oFile=oFSO.OpenTextFile("C:\pcdata\Troubleshooting\ff_scripts\PCDataSupportDashboard\printerfile.txt",1)
    		Do Until oFile.AtEndOfStream
    		 text=oFile.ReadLine
    		 'MsgBox text
    		  Dim a		
    		  Dim b
    		  a=Split(text,"-")
                      Set opt = document.createElement("option")
                      opt.Value = a(1)
                      opt.Text  = a(0)
                      Document.getElementById("dropdown1").add opt
    				  
    		  b=Split(text,"-")
                      Set opt2 = document.createElement("option")
                      opt2.Value = b(2)
                      opt2.Text  = b(0)
                      Document.getElementById("dropdown1").add opt2
    		Loop
    		oFile.Close
    	End Sub


    The issue is when I am trying to create the down menu I am not sure how to handle the split. That code is below:

    Sub Populatedropdown2
    		Set e = Document.getElementById("dropdown1")
    		document.getElementById("printername").InnerText=e.Options(e.selectedIndex).Text
    		document.getElementById("printerip").InnerText=e.Options(e.selectedIndex).Value
    		document.getElementById("printerip2").InnerText=e.Options(e.selectedIndex).Value
    		document.getElementById("myAnchor").href = "http://" & e.Options(e.selectedIndex).Value 
    	End Sub

    Here is the section I need to display the IP address with leading zeros: Specifically where it says printerip2

    <b>ZM400</b><br/>
    		Follow these instructions step by step to reset Printer IP address.</br>
    		The IP address you will want to enter for <b><font color=red><span id="printername">(Select Printer)</span></font></b> &nbsp;will be&nbsp;<b><font color=red><span id="printerip2">(Select Printer)</span></font></b>
    		<li>Enter the Setup by pressing Setup/Exit once</li>
    #Then the code below needs the IP address without leading
    #zeros: 
    
    #Specifically the -- > Click id="myanchor" href="#"> here
    



    <li>Once the printer is truned back on, follow the steps described in <a href="C:\pcdata\Troubleshooting\ff_scripts\PCDataSupportDashboard\img\PCDATA Printer Troubleshooting ZM400 - Additional Steps v1.0.pdf">this</a> document to make sure other printer settings are correct. Click <a id="myAnchor" href="#"> here </a> to launch the printer web page to check settings.</li>





    • Edited by Broggy69 Monday, April 9, 2018 1:50 PM Formmating issues
    • Moved by Bill_Stewart Friday, July 27, 2018 6:12 PM This is not "debug/fix/rewrite my script for me" forum
    Monday, April 9, 2018 1:45 PM

Answers

  • There is no way to understand your issue without a simple example HTA.  You show code and state it doesn't work but we cannot run any of the code to understand.

    Create a simple HTA that shows what you are trying to do and a clear statement of what is not happening.


    \_(ツ)_/

    'After the printer file is split I have an .hta script which 'I shared the code to create a drop as shown below.
    


    Currently, it only shows an IP address as 10.11.10.10 As shown below. However this I need to show 010.011.010.010.

    After these instructions are followed then the user will click on a link to open a webpage to the printer.  which cannot of the leading zeros.

    The Sub dropdown2 is the .hta code.

    
    • Edited by Broggy69 Monday, April 23, 2018 2:54 PM Formmating issues with plain text being converted to html code
    • Marked as answer by Broggy69 Friday, February 15, 2019 3:21 AM
    Monday, April 23, 2018 2:52 PM

All replies

  • Bumping. 
    Thursday, April 19, 2018 4:51 PM
  • There is no way to understand your issue without a simple example HTA.  You show code and state it doesn't work but we cannot run any of the code to understand.

    Create a simple HTA that shows what you are trying to do and a clear statement of what is not happening.


    \_(ツ)_/

    Thursday, April 19, 2018 4:58 PM
  • There is no way to understand your issue without a simple example HTA.  You show code and state it doesn't work but we cannot run any of the code to understand.

    Create a simple HTA that shows what you are trying to do and a clear statement of what is not happening.


    \_(ツ)_/

    'After the printer file is split I have an .hta script which 'I shared the code to create a drop as shown below.
    


    Currently, it only shows an IP address as 10.11.10.10 As shown below. However this I need to show 010.011.010.010.

    After these instructions are followed then the user will click on a link to open a webpage to the printer.  which cannot of the leading zeros.

    The Sub dropdown2 is the .hta code.

    
    • Edited by Broggy69 Monday, April 23, 2018 2:54 PM Formmating issues with plain text being converted to html code
    • Marked as answer by Broggy69 Friday, February 15, 2019 3:21 AM
    Monday, April 23, 2018 2:52 PM