Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object required error

Status
Not open for further replies.

princessk1

Programmer
Feb 28, 2002
74
CA
I am trying to access the value from a textbox I created in ASP in a vbscript procedure.

I am getting the 'object required' error. How do you create an object for a textbox in vbscript?
 
you might want to post your code. the error may be the syntax of how you're trying to get the information as opposed to actually needing an object.
 
This question would be better addressed to the ASP forum.

Ok, I'll take a stab at this. Please forgive me if I misunderstand your question.


If your VBScript procedure is part of your ASP logic, you can't access something like a textbox as an object, because it doesn't exist.

A textbox is only a textbox at the browser, it is part of the HTML output of your ASP page being processed.


If you are talking about a VBScript procedure that runs at the browser, there isn't any real problem. Just give the textbox a name and an id (there is almost never a good reason for them not to be the same value) and reference them in your VBScript as an object:
Code:
<html>
<head>
<script language=vbscript>
Sub button1_onClick()
  MsgBox text1.value
End Sub
</script>
</head>
<body>
<input type=text name=text1 id=text1><br>
<input type=button name=button1
  id=button1 value=&quot;Get Value&quot;>
</body>
</html>
That's all there is to it!


My guess though is that you may be trying to access the textbox object in your ASP code. For example:
Code:
<%@ language=vbscript %>
<%
Dim strText

Sub GetText()
  strText = text1.value
End Sub

GetText
%>
<html>
<head>
</head>
<body>
<input type=text name=text1 id=text1><br>
<input type=button name=button1
  id=button1 value=&quot;Get Value&quot;>
</body>
</html>
This is doomed to fail. While the ASP script is being executed there isn't any text1 yet, just some HTML that will be output to create a text1 at the user's browser after the ASP page finishes executing.


The way an ASP page gets the contents (or value) of HTML elements is when a form submit takes place which makes a server request for an ASP page (a GET or POST request). Then, after the submit is done the ASP page can reference the Request object's QueryString collection (for GET requests) or the Request object's Form collection, as in: Request.Form(&quot;text1&quot;) (for POST requests).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top