Click to See Complete Forum and Search --> : Event on input click


wheelshot
09-19-2005, 09:41 AM
I have a Treeview and within, there are input buttons. On click i would like to launch a function that will fill an HTML table. It keeps telling me that an object is required but im not good enough to debug yet :(

Here's the place where the call is made:

Out("<li "& strStyle &" class=file><input type=""button"" value=""" & Node.Text & """ onClick=""FillTable(" & Node.ID & ")""> - <a class=treeview href=""" & Node.Href & """ target=""" & Node.Target & """ title=""" & Node.ToolTipText & """>Info</a>")


Here's my function: in VBScript

Public Sub FillTable(nodeID)
Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strConn

Dim RS, parentid
Set RS = Conn.Execute("SELECT * FROM Mats WHERE ParentID=" & nodeID & " ORDER BY Text")


If Not RS.EOF Then
Do While Not RS.EOF
parentid=RS("ParentID")

RS.MoveNext

Loop
RS.Close
End If
Set RS = Nothing
Conn.Close
Set Conn = Nothing


End Sub


Thanks for your help

slyfox
09-19-2005, 05:08 PM
Run that code again, then right click and view source, then see if you can find the function you're trying to call... you won't find it because it's not there.

What's happening here is that you are mistaking server side code for client side code, or is it the other way around?

You see, you have two types of code you got to use, server side (ASP - VBScript) and client side (JavaScript, VBScript will also work on client side, but it's not compatable with browsers other than IE)

Server side code runs on the server only, client side runs on clients computer.

So this is what happened with your code:
The function you called is in your ASP code (which gets interprated first at the server before page loads to the client)
Then, once page is loaded on clients computer, you cannot call an ASP function "without reloading the page"
When using client side script (eg. javascript) you have to work with what you got on that page, "or what you have pre-loaded" to it with your ASP code before the page was displayed on users pc.

Hope it helps you, but best is you go and read about it, this link is a very good place to go: http://www.w3schools.com/asp/default.asp

Good luck :)

wheelshot
09-19-2005, 05:35 PM
Thanks a lot, i can see my mistake now. What ill do is populate the recordset in the ASP and pass it to client side and then ill populate my table.

Thanks again!