[thelist] Brain fart html w/asp

James Aylard webmaster at equilon-mrc.com
Thu Apr 11 15:58:00 CDT 2002


Rob,

> I'm having a brain fart right now. I know how to do this in javascript,
but
> how different is it in ASP with HTML

    Hmm. Do you mean VBScript and HTML? Using ASP on the server side in no
way dictates that you need to use VBScript on the client side. If you _want_
to use VBScript on the client, just remember that only IE 3+ will understand
it.

> <input type="button" name="Ok" value="Ok" onClick(call doit())>

> Is the onClick part right or what do I need to do to call a function when
> the button is clicked without using javascript.

    No, the onclick part is messed up, regardless of the scripting language
used. The mixed case of onClick is okay, but you are missing your "=". Don't
use the outer parens around the whole thing. And you probably don't need the
"call" statement. So:

<input type="button" name="Ok" value="Ok" onclick="doit()">

    You can also leave out the event handler in the input element and write
your script this way, especially if this particular button is the only one
that will execute the code:

<script type="text/vbscript">
  Sub Ok_OnClick
    ' Run some code
  End Sub
</script>

> can javascript call VBScript functions and the other way around?

    Yes.

> Can you use Javascript and VBScript in the same page, sometimes working
> together?

    Yes, depending on what you mean by "working together". Each language
needs to be isolated within its own <script> element, but you can toss
variables and call functions back and forth between the two.
    One critical point: the first script block appearing on the page sets
the default language for the page. Then, any script that appears within
event handlers in the HTML needs to be consistent with that language. For
instance, this will cause an error:

<script type="text/vbscript"></script>
<script type="text/javascript"></script>
<input type="button" onclick="window.open();">

    The semicolon in the onclick event handler is JavaScript and will cause
a parsing error when the page loads. Switching the script blocks or removing
the semicolon will eliminate the error. You can also append the
"javascript:" pseudo-protocol to the statement, e.g.:

onclick="javascript:window.open();"

    But I come back to the question: are you sure that you need to use
VBScript on the client?

James Aylard




More information about the thelist mailing list