Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 15th, 2003, 03:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default OnKeyPress to call VBSCRIPT validation

I am looking for an VBSCRIPT example for a function called by an OnKeyPress or OnKeyDown event associated with an input field or textarea. The example should contain only indirect references to the field in question so that other properties of the field can be referenced - IOW, no hard-coded field names anywhere in the fnuction.

My attempts to translate JavaScript to VBScript have been unsuccessful and frustrating, so I'd appreciate ONLY VBScript examples, please. Thanks!
 
Old September 16th, 2003, 06:18 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

In your form:
Code:
<input type="text" onKeyPress="showData Me">
In your script block
Code:
Function showData(Sender)
  alert(Sender.value & "(" & event.keyCode & ")")
End Function
Or remove the Me from the onKeyPress call and use event.srcElement instead of Sender in the function.

--

Joe
 
Old September 16th, 2003, 07:03 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default

Exactly what I was looking for. Thank you!
 
Old September 16th, 2003, 09:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default

Now can somebody successfully translate it to VBSCRIPT?
 
Old September 16th, 2003, 09:50 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It is in VBScript.

--

Joe
 
Old September 16th, 2003, 10:07 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default

Sorry. I'm used to seeing "MsgBox", not "Alert", in VB, and wasn't aware it was permitted.





Similar Threads
Thread Thread Starter Forum Replies Last Post
onkeypress move to next control [except when the f kamii47 ASP.NET 2.0 Professional 2 September 11th, 2007 03:47 AM
onkeypress not supported in asp.net 2.0 ?? savan_thakkar ASP.NET 2.0 Professional 1 March 19th, 2006 04:46 PM
Onkeypress Fia VB.NET 2002/2003 Basics 0 May 6th, 2005 05:19 AM
IS it possible to call Outlook from VBScript? nfoliveira VBScript 1 March 19th, 2004 09:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.