Hmm...
A couple of observations:
Event-handler script really should be declared in the <HEAD></HEAD> portion of the page rather than the body. Few browsers require this for the approach you have used, and as far as I know any of them that support VBScript and not just Javascript are somewhat forgiving of this. Some types of event-handling script just won't work declared at the end or in the middle of the <BODY> though. You really should strive to declare all script on a page within a single <SCRIPT> block, and
that should be in the <HEAD>. Sure, there are exceptions but these are few. It is considered good practice to avoid intermixing script and HTML within the page whenever possible. There is a lot of hacked up ASP out there that is going to need a complete rewrite for .Net someday because the author is still writing stuff according to "standards" from 1997 when people didn't really understand ASP yet.
Your TEXTAREA has a
name but doesn't have an
id. The
name is really only meant to give names to form elements for submission to the host, it wasn't intended to assign an element a scriptable identity. This is what
id is for. People screwed this up so royally in early efforts at DHTML that many browsers will be forgiving here too and "assume an
id value equal to the
name, but in some cases this can't happen due to ambiguity. Always declare both
name and
id and
unless you have a very good reason always make them the same. It may seem like a pain, but it will keep you out of trouble. Besides, this is why tools like InterDev came out in the mid 90s - to automate much of this stuff.
DHTML is not VB. As a result, you will find that the DHTML object model is quite different from VB's in many regards. And wishing seldom makes things so in any programming environment!
Your example code assumes that a TEXTAREA object has a boolean property called "bold." Here is what you need:
Code:
Public Sub cmdmakebold_onClick()
content.style.fontWeight="bold"
End Sub
To be a successful DHTML developer you need to study the browser document object model and CSS.
I find darned few good introductions are available, mostly because it is hard to get into much detail without things bogging down in the differences between the ways different browsers handle the same things. Since you seem to have chosen VBScript as your DHTML scripting language, you have narrowed your target browsers to Internet Explorer 4+ (older versions of IE simply being ridiculous to contemplate at this late date).
That's good news, because there is excellent reference information available, if not a lot of beginner tutorials! Run, don't walk, to
Be sure to click on Web Development in the navigation tree at the left. There is a wealth of good information here.