ASP object required error - vbscript

N

News Groups

Dear Group
I am trying to use the following code to refer to a form and control on my
form. I am supposed to be using VBSCRIPT for this code.
I always get an "object required: 'document' " error:

<%
Dim Myform
Set Myform = document.forms.thisform
Myform.textbox1.value = "fish" %>

None of this code will work. Always get an error.
Using Visual Interdev, plain ole ASP, and vbscript, and Win XP Pro with IIS
5.1

What am I missing or doing wrong???

Thanks

eric
 
M

Mark Schupp

Document is a client-side object supplied by the browser to the local
scripting environment. You are trying to use it in server side code.
 
A

Aaron [SQL Server MVP]

<%
Dim Myform
Set Myform = document.forms.thisform

You are seriously confusing client-side and server-side concepts. ASP
executes as, basically, a two-step process. ASP runs on the server, and so
has no knowledge of client-side things like forms. Once ASP finishes
running, the client-side code runs and, likewise, it has no knowledge of
server-side subs, functions, etc. Think about getting a passport, you need
to get your photo first, then apply for the passport. Does it make sense to
have your passport # printed on the photo before your passport # has been
issued?

You can make the two communicate in different ways, but what you're doing
isn't one of them.

To replicate what you're trying to do:

<%
myValue = "fish"
%>
<input type=text name=textbox1 value='<%=myValue%>'>

Not sure why you are "supposed to be using VBScript" ... you should use
JavaScript on the client so that your pages will work in Firebird/Firefox,
Mozilla, etc.
 
J

Jeff Cochran

Dear Group
I am trying to use the following code to refer to a form and control on my
form. I am supposed to be using VBSCRIPT for this code.
I always get an "object required: 'document' " error:

<%
Dim Myform
Set Myform = document.forms.thisform
Myform.textbox1.value = "fish" %>

None of this code will work. Always get an error.
Using Visual Interdev, plain ole ASP, and vbscript, and Win XP Pro with IIS
5.1

What am I missing or doing wrong???

Mixing VBScript and Javascript with something I can't identify...

You haven't created a Myform object is what's likely causing the
error, but I have no idea why you would want to. What exactly are you
trying to accomplish?

Jeff
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top