[AccessD] OT: Passing Variables - VBScript

Mitsules, Mark Mark.Mitsules at ngc.com
Mon Jun 2 11:54:33 CDT 2003


Group,

This is my first real attempt at developing an HTML application (.HTA) using
VB Script.  Given that the user makes a selection from this element:

<form>
 <select name="SelectPrinter" onChange="???What goes here???">
   <option value="Not Selected" selected>
    Please select a printer.
   </option>
   <option value="\\ServerName\PrinterName1">
    Printer #1
   </option>
   <option value="\\ServerName\PrinterName2">
    Printer #2
   </option>
 </select>
</form>

...?how do I pass their selection to a button element,

<INPUT TYPE="Button" NAME="Button001" VALUE="Install">


...that will utilize a routine like:

Sub Button001_OnClick()
End Sub


I provided an example below that uses separate buttons (with an associated
separate function) for each printer (...which works), but this approach is
not very elegant.


TIA,

Mark



Function InstallPrinter(PrinterPath)
  Set WshNetwork = CreateObject("WScript.Network")
  WshNetwork.AddWindowsPrinterConnection PrinterPath
End Function

Function SetDefaultPrinter(PrinterPath)
  Set WshNetwork = CreateObject("WScript.Network")
  WshNetwork.SetDefaultPrinter PrinterPath
End Function

Function Button001_OnClick()
  PrinterPath = "\\ServerName\PrinterName1"
  InstallPrinter(PrinterPath)
End Function

Function Button001A_OnClick()
  PrinterPath = "\\ServerName\PrinterName1"
  InstallPrinter(PrinterPath)
  SetDefaultPrinter(PrinterPath)
End Function

<FORM NAME="Form001">
 <INPUT TYPE="Button" NAME="Button001" VALUE="Install Printer"> </FORM>

<FORM NAME="Form001A">
 <INPUT TYPE="Button" NAME="Button001A" VALUE="Set as Default Printer">
</FORM>


More information about the AccessD mailing list