Object Does not support this property or Method error

R

Roberta McGervey

I have the following code:

<Script LANGUAGE=vbscript RUNAT=Server>

for i =0 to document.form1.elements.count-1

response.write "test"

next

</Script>

When it gets to the line for i=0.... the error message pops up stating that
Object does not support this Property or Method.



I have a from name form1.



Please help.
 
C

Curt_C [MVP]

it's because the server doesn't know what
document.form1.elements.count
is, that's my bet.
 
R

Roberta McGervey

I got the following code from MSDN to use as an example. So if I am mixing
to two languages it is because the MSDN is incorrect.

<SCRIPT LANGUAGE="VBScript">
<!-
Sub cmdChange_OnClick
For i=0 To Document.frmForm.Elements.Count-1
Document.frmForm.Elements(i).Value="Changed!"
Next
End Sub
->
</SCRIPT>
 
R

Roberta McGervey

I'm new to this so is there a setting on the web server I can change so that
it recognizes this statement?

I found a different way to do what I want to do but it would require more
code. From the interdev and vbscript courses I took online this statment
should work.

Thanks.
 
B

Bob Barrows

Roberta said:
I'm new to this so is there a setting on the web server I can change
so that it recognizes this statement?

No. "document" is a client-side DHTML object. Server-side code knows nothing
about client-side DHTML.
I found a different way to do what I want to do but it would require
more code. From the interdev and vbscript courses I took online this
statment should work.

Then you need to reread those sources. You can never reference a client-side
object or property from server-side code, and vice versa.
Your code would work fine if you removed the "RUNAT=Server" piece from the
script tag.

Bob Barrows
 
B

Bob Barrows

Roberta said:
I got the following code from MSDN to use as an example. So if I am
mixing to two languages it is because the MSDN is incorrect.

No, it's because your code is incorrect.

MSDN's code:
<SCRIPT LANGUAGE="VBScript">

Your code:
See the difference?

Actually, Stuart was incorrect: you are not mixing two languages. Your
mistake is attempting to use a server-side script block (RUNAT=Server) to
run code that can only run on the client.

This is the main obstacle to people attempting to learn to use asp (myself
included): learning the difference between server-side code and client-side
code. There are many asp tutorial sites out there (www.asp101.com, etc.)
that do a reasonable job of explaining the differennce better than i can do
in an email message.

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top