[AccessD] OT: Passing Variables - VBScript

Bob Gajewski bob at renaissancesiding.com
Mon Jun 2 12:33:09 CDT 2003


Mark

If all that you are looking for is the "onChange" code ...

<script language="JavaScript">
function setDefaultPrinter(device){
	var DefaultPrinter = form.SelectPrinter.options[form.SelectPrinter.selectedIndex].value;
' whatever else code you need to run goes here ...
	}
</script>

<body>
<form name=form>
Set the default printer: 
<select name=SelectPrinter onFocus="SelectPrinter.value='none'" onChange="setPrinter(this.form)">
	<option value="none" selected>-- None --</option>
	<option value="\\ServerName\PrinterName1">Printer #1</option>
	<option value="\\ServerName\PrinterName2">Printer #2</option>
</select>
<input type="submit" value="Set Default Printer" onClick="javascript:setDefaultPrinter(this.form)">
</form>

Regards,
Bob Gajewski


On Monday, June 02, 2003 12:55 PM, Mitsules, Mark [SMTP:Mark.Mitsules at ngc.com] wrote:
> 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