469,270 Members | 1,037 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Microsoft VBScript runtime (0x800A01A8)

The ASP page has a combo box with id list, and when user click the
particular id, it will show the name in the text box. My attempt was when
the user have event on combo box, it will call JavaScript showempname(), and
it will then look up the name by executing SQL statement.

However, the following code has the following error:

Microsoft VBScript runtime (0x800A01A8)
Object required on line " sqlStmt = "select * from employee where EmployeeID
= "
<script language="JavaScript">
function showempname()
{
if (document.eventform.id.length > 1)
{
<%
Dim objRS
set objRS = Server.CreateObject("ADODB.Recordset")
sqlStmt = "select * from employee where EmployeeID = " _
& "'" & document.eventform.id.value & "'" & ";"
objRS.Open sqlStmt, strConnect
document.eventform.empname.value = objRS("FirstName")
Set objRS = Nothing
%>
}
}
</script>
</head>

<body>
<form name="eventform" action method="post">
<select name="id" onchange="showempname()">
<option value="1001">1001</option>
<option value="1002">1002</option>
<option value="1003">1003</option>
</select>

<P>Name: <input type="text" name="empname">
Any ideas?? thanks!!
Jul 19 '05 #1
3 7111

"Matt" <ma*******@hotmail.com> wrote in message
news:eF**************@TK2MSFTNGP11.phx.gbl...
<%
Dim objRS
set objRS = Server.CreateObject("ADODB.Recordset")
sqlStmt = "select * from employee where EmployeeID = " _
& "'" & document.eventform.id.value & "'" & ";"
Any ideas?? thanks!!


You're mixing client side code with server side code.

You need to use REquest.Form("ID") to read the form value when the page is
posted back to the server.

Also, I would say using the name 'ID' for your <select> is just asking for
trouble - rename it something unique that isn't a common key word.

eg 'EmpID'

Jul 19 '05 #2
Matt,
you are trying to do something really odd
You cannot mix clientside javascript and server side
code.
--
Roji. P. Thomas

--------------------------------------
"Matt" <ma*******@hotmail.com> wrote in message
news:eF**************@TK2MSFTNGP11.phx.gbl...
The ASP page has a combo box with id list, and when user click the
particular id, it will show the name in the text box. My attempt was when
the user have event on combo box, it will call JavaScript showempname(), and it will then look up the name by executing SQL statement.

However, the following code has the following error:

Microsoft VBScript runtime (0x800A01A8)
Object required on line " sqlStmt = "select * from employee where EmployeeID = "
<script language="JavaScript">
function showempname()
{
if (document.eventform.id.length > 1)
{
<%
Dim objRS
set objRS = Server.CreateObject("ADODB.Recordset")
sqlStmt = "select * from employee where EmployeeID = " _
& "'" & document.eventform.id.value & "'" & ";"
objRS.Open sqlStmt, strConnect
document.eventform.empname.value = objRS("FirstName")
Set objRS = Nothing
%>
}
}
</script>
</head>

<body>
<form name="eventform" action method="post">
<select name="id" onchange="showempname()">
<option value="1001">1001</option>
<option value="1002">1002</option>
<option value="1003">1003</option>
</select>

<P>Name: <input type="text" name="empname">
Any ideas?? thanks!!

Jul 19 '05 #3
so how can i handle this in my case?

well, if the user select the EmployeeID in combo box, and then click the
submit button, and it will look up database and show the Employee Name in
the text box, this is easy.

But my case is: when the user select the employeeid in combo box, it will
fire the onchange event, and then look up database and show the employee
name in the text box. There is no submit button.

I really have no idea how to do that.
"Roji. P. Thomas" <la********@somewhere.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Matt,
you are trying to do something really odd
You cannot mix clientside javascript and server side
code.
--
Roji. P. Thomas

--------------------------------------
"Matt" <ma*******@hotmail.com> wrote in message
news:eF**************@TK2MSFTNGP11.phx.gbl...
The ASP page has a combo box with id list, and when user click the
particular id, it will show the name in the text box. My attempt was when the user have event on combo box, it will call JavaScript showempname(),

and
it will then look up the name by executing SQL statement.

However, the following code has the following error:

Microsoft VBScript runtime (0x800A01A8)
Object required on line " sqlStmt = "select * from employee where

EmployeeID
= "
<script language="JavaScript">
function showempname()
{
if (document.eventform.id.length > 1)
{
<%
Dim objRS
set objRS = Server.CreateObject("ADODB.Recordset")
sqlStmt = "select * from employee where EmployeeID = " _
& "'" & document.eventform.id.value & "'" & ";"
objRS.Open sqlStmt, strConnect
document.eventform.empname.value = objRS("FirstName")
Set objRS = Nothing
%>
}
}
</script>
</head>

<body>
<form name="eventform" action method="post">
<select name="id" onchange="showempname()">
<option value="1001">1001</option>
<option value="1002">1002</option>
<option value="1003">1003</option>
</select>

<P>Name: <input type="text" name="empname">
Any ideas?? thanks!!


Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by PaulieS | last post: by
reply views Thread by =?Utf-8?B?TWF0dCBDYWxob29u?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.