Click to See Complete Forum and Search --> : VBScript - Referencing form controls


Paul Jr
10-23-2004, 04:54 PM
Salutations,

I have recently started dabbling in VBScript, and I'm wondering how exactly one would reference form controls in VBScript. Is it even possible?

NelsonN
10-23-2004, 06:13 PM
Is this helpful?

http://www.ftponline.com/archives/premier/mgznarch/vbpj/2000/11nov00/bb0011/bb0011.asp

Or maybe this is what your looking for?

http://www.csharpfriends.com/quickstart/aspplus/doc/webcontrolsref.aspx

buntine
10-23-2004, 08:01 PM
I assume your referring to HTML form controls.

It is done very similar to JavaScript.

<script Language="VBScript">
Function ShowMessage()
MsgBox "Hello World!"
End Function
</script>
...
<input type="button" name="btnClick" value="Click Me" onclick="ShowMessage" />

Regards.

buntine
10-23-2004, 08:03 PM
Here is a good tutorial I found: http://www.functionx.com/vbscript/Lesson06.htm

Regards.

Paul Jr
10-23-2004, 08:53 PM
The only problem is that I've developed a habit of not giving my forms names (since it isn't valid in XHTML). So if the form has no name, how can I access it? In JavaScript, I'd just use document.forms[0] to reference the first form on the page. That won't work, though. :confused: Is there any other way? Must I give my form a name?

buntine
10-24-2004, 01:55 AM
You should not have to name your form. Though, you will need to name your controls.

Item.UserProperties.Find("YourField") = "Value"

By the way, why are you bothering learning this? VBScript is rarely (if ever) used for client-side scripting. You may as well learn ASP.

Regards.

Paul Jr
10-24-2004, 01:13 PM
Originally posted by buntine
You should not have to name your form. Though, you will need to name your controls.

Item.UserProperties.Find("YourField") = "Value"

Yes, I just figured out why it wasn't working. :D VBScript is different from JS in that when accessing numerically indiced array elements, you use parentheses instead of square brackets (document.forms(0) not document.forms[0]). :D My bad, my bad.

Originally posted by buntine
By the way, why are you bothering learning this? VBScript is rarely (if ever) used for client-side scripting. You may as well learn ASP.
Well, I'm not exactly sure. It's beginning to seem rather pointless. I would, however, like to learn ASP.net, but it's nothing more than a pipe dream if I can't get a server set up (which it appears I can't, unless I upgrade to XP Pro).

Thanks for everyone's help. :)

buntine
10-24-2004, 08:19 PM
Thats OK.

What OS are you on? IIS should ru on every Windows platform (except Windows ME).

Download Apache Tomcat and give JSP a go. If you have any JavaScript experience, the syntax should be easy to pick up.

Regards.

Paul Jr
10-24-2004, 09:59 PM
I'm running XP Home. From what I read, it's either impossible or really, really hard to get IIS or PWS (or the like) running on XP Home.

Do you think JSP is worthwhile to learn? Quite frankly, I never even considered it. I don't see it around that much, and I don't even know a thing about it. :confused: PHP and ASP seem to be the two primary server-side languages (other than CGI-Perl, which I am also looking into).

buntine
10-24-2004, 10:06 PM
Its huge in the business world. It is gaining popularity everyday, too. Most of the blog guys just use PHP or ASP.

Its definetely worth learning.

Regards.

Paul Jr
10-24-2004, 10:20 PM
All righty then, I guess I have my work cut out for me. ;)

Know of any good places to get info on this? Where I should get Tomcat, how to install, some tutorials -- the works?

buntine
10-25-2004, 06:40 AM
Buy a book if your serious about it.

You can get Tomcat from: http://jakarta.apache.org/tomcat/
The docs are at: http://java.sun.com/products/jsp/docs.html
A handy tutorial: http://www.jsptut.com

Regards.

Paul Jr
10-25-2004, 05:55 PM
A book, eh? I wasn't actually planning on it. I figure I can learn the basics and whatnot online -- same thing I did with PHP. I was going to pick up either a C++ or Java book, though, depending on which one I decided upon.

Thanks for the help and links. :)


***EDIT***
Ahhh, told you I didn't know a thing about it. According to the Sun website, it's more or less Java on the web?


***EDIT 2***
Just want to make sure I download the right thing (best to do it one time with dialup). I'm quite sure I download one from the 5.0.28 list here (http://jakarta.apache.org/site/binindex.cgi#tomcat-5.0), but which one?