[AccessD] OT: Passing Variables - VBScript

Drew Wutka DWUTKA at marlow.com
Mon Jun 2 14:08:52 CDT 2003


<Script language="VBScript">
Function DoSomething()
msgbox document.MyFormName.SelectPrinter.value
End Function
</Script>

Then put DoSomething() in place of the ???What goes here??? spot.(Keep the
double quotes around it.)

Just an FYI, using VBScript is going to limit your clients to using IE in
most cases.  I personally use a lot of VBScript on our Intranet, because all
Intranet clients use IE.

Drew
-----Original Message-----
From: Mitsules, Mark [mailto:Mark.Mitsules at ngc.com]
Sent: Monday, June 02, 2003 11:55 AM
To: 'AccessD'
Subject: [AccessD] OT: Passing Variables - VBScript


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>
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list