Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Document.getElementByID("ID").innerHTML = stuff

3,683 views
Skip to first unread message

KDawg44

unread,
Nov 28, 2007, 12:48:14 PM11/28/07
to
Hi,

In JavaScript I can do something like:

document.getElementByID("tally").innerHTML = HTMLOutput

and it will put the HTML variable in the

<span id = "tally"></span>

part.

Is there a way to do this using VBScript?

Thanks.

Tom Lavedas

unread,
Nov 28, 2007, 12:59:19 PM11/28/07
to

That is all part of the browser's DOM and works with either language,
though VBS is only supported in IE.

Why do you ask? Are you having a specific problem?

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

ekkehard.horner

unread,
Nov 28, 2007, 1:11:29 PM11/28/07
to
KDawg44 schrieb:
The surrounding code will certainly be different, but the line
you cited can be copied&pasted from Javascript to VBScript (because
both languages use the same DOM).

KDawg44

unread,
Nov 28, 2007, 1:30:13 PM11/28/07
to

Well, I am getting an error:


Microsoft VBScript runtime error '800a01a8'

Object required: 'window'

/page.asp, line 539

and the line is:

window.document.getElementById("tally").innerHTML = HTMLOutput


Thanks.

ekkehard.horner

unread,
Nov 28, 2007, 2:09:59 PM11/28/07
to
KDawg44 schrieb:
I suspect you execute the line in question on the server; the
window object is provided by the browser (i.e. IE) and dynamically
changing the page's content makes sense in client side scripting
only.
What exactly do you want to achieve?

Tom Lavedas

unread,
Nov 28, 2007, 2:17:26 PM11/28/07
to

Yes. Note that you originally posted ...

document.getElementById("tally").innerHTML = HTMLOutput

and I said that should work in IE, regardless of the language
selected.

Now you are posting ...

window.document.getElementById("tally").innerHTML = HTMLOutput

with an error that the object window is required. That's because
everything in an HTML/ASP page is presumed to be part of the windows
class/object, as I understand the DOM. Therefore, you are really
trying to reference a window object in the window class. Drop the
window reference and it should work.

KDawg44

unread,
Nov 28, 2007, 2:51:47 PM11/28/07
to
On Nov 28, 2:09 pm, "ekkehard.horner" <ekkehard.hor...@arcor.de>
wrote:

Ahhh yes that would make sense. My ASP page does some prints
responses to a survey throughout the page, and does some tallies
throughout, then I want to print some HTML with the result of the
tallies back at the top of the page.

ekkehard.horner

unread,
Nov 28, 2007, 3:00:38 PM11/28/07
to
Tom Lavedas schrieb:
As can be seen from:

<html>
<head>
<hta:application id = "dynspan" />
<title>dynspan</title>
<meta http-equiv = "content-script-type" content = "text/vbscript"/>
<script language = "VBScript" type = "text/vbscript">
'<![CDATA[

''= write to span "tally"
' ============================================================================
Sub doIt()
' document.getElementById("tally").innerHTML = "HTML<b>Output</b>"
window.document.getElementById("tally").innerHTML = "HTML<b>Output</b>"
End Sub

''= refreshes the HTA page, which includes re-running any Windows_Onload code
' ============================================================================
Sub reloadHTA()
location.reload True
End Sub

']]>
</script>
</head>
<body>
<span id = "tally">will be replaced</span>
<hr />
<input type = "BUTTON" value = "write to tally" onclick = "doIt">
<hr />
<input type = "BUTTON" value = "reload" onclick = "reloadHTA">
</body>
</html>

there is no problem in *client side* script to access the window object.

Tom Lavedas

unread,
Nov 28, 2007, 3:41:37 PM11/28/07
to
On Nov 28, 3:00 pm, "ekkehard.horner" <ekkehard.hor...@arcor.de>
wrote:

> Tom Lavedas schrieb:
>
> > On Nov 28, 1:30 pm, KDawg44 <KDaw...@gmail.com> wrote:
> >> On Nov 28, 12:59 pm, Tom Lavedas <tglba...@cox.net> wrote:
>
> >>> On Nov 28, 12:48 pm, KDawg44 <KDaw...@gmail.com> wrote:
> >>>> Hi,
> >>>> In JavaScript I can do something like:
{snip}

>
> there is no problem in *client side* script to access the window object.

I stand corrected.

0 new messages