Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 11:00 AM
Matt
Guest
 
Posts: n/a
Default 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!!


  #2  
Old July 19th, 2005, 11:00 AM
Dan Boylett
Guest
 
Posts: n/a
Default Re: Microsoft VBScript runtime (0x800A01A8)


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

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'



  #3  
Old July 19th, 2005, 11:00 AM
Roji. P. Thomas
Guest
 
Posts: n/a
Default Re: Microsoft VBScript runtime (0x800A01A8)

Matt,
you are trying to do something really odd
You cannot mix clientside javascript and server side
code.


--
Roji. P. Thomas

--------------------------------------
"Matt" <mattloude@hotmail.com> wrote in message
news:eF9lC8o1DHA.4060@TK2MSFTNGP11.phx.gbl...[color=blue]
> 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(),[/color]
and[color=blue]
> 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[/color]
EmployeeID[color=blue]
> = "
>
>
> <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!!
>
>[/color]


  #4  
Old July 19th, 2005, 11:00 AM
Matthew Louden
Guest
 
Posts: n/a
Default select ID in combo box and show name in text box without submit button

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" <lazydragon@somewhere.com> wrote in message
news:%23lxxbCp1DHA.484@TK2MSFTNGP10.phx.gbl...[color=blue]
> Matt,
> you are trying to do something really odd
> You cannot mix clientside javascript and server side
> code.
>
>
> --
> Roji. P. Thomas
>
> --------------------------------------
> "Matt" <mattloude@hotmail.com> wrote in message
> news:eF9lC8o1DHA.4060@TK2MSFTNGP11.phx.gbl...[color=green]
> > 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[/color][/color]
when[color=blue][color=green]
> > the user have event on combo box, it will call JavaScript showempname(),[/color]
> and[color=green]
> > 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[/color]
> EmployeeID[color=green]
> > = "
> >
> >
> > <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!!
> >
> >[/color]
>
>[/color]


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles