OnClick Question

S

SyrU

I have the below code. I am trying to send information to a subroutine, I
am getting an Object Required Error.

<input type="button" name="pSearch" value="Search"
onclick="DisplayRecords()">

Then in my ASP page I have this

Sub DisplayRecords()

dim conn
dim strsql
dim mycount

....
....

End Sub

I think I am doing this correctly.
 
S

SyrU

Hmmm, thanks didn't realize that. Is there any another way I can have a
user click on a button and run a sub routine or do I have to pass the value
to another page?.
 
R

Ray Costanzo [MVP]

It can be the same page, different page, different server, different site -
it doesn't matter. But, regardless, you'll have to hit a server again.
Example:


<%
If Request.Querystring("x") = "1" Then
Response.Write "Okay, NOW the code in here will run..."
'''code, code, code
End If
%>


<button onclick="location.href+='?x=1'">Run a sub</button>


See, instead of calling a sub from your button, you call the page again, but
pass something in the querystring that can tell your SERVER-side code that
it should do something. Does that make sense at all?

Ray at home
 
S

SyrU

Yes, it does. Thanks Ray


Ray Costanzo said:
It can be the same page, different page, different server, different site -
it doesn't matter. But, regardless, you'll have to hit a server again.
Example:


<%
If Request.Querystring("x") = "1" Then
Response.Write "Okay, NOW the code in here will run..."
'''code, code, code
End If
%>


<button onclick="location.href+='?x=1'">Run a sub</button>


See, instead of calling a sub from your button, you call the page again, but
pass something in the querystring that can tell your SERVER-side code that
it should do something. Does that make sense at all?

Ray at home
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top