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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call a function with Onclick

Status
Not open for further replies.

KryptoS

Programmer
Feb 7, 2001
240
BE
Hey everybody,

I have a problem. I want to call an asp function when I click on a link. Plus (if possible) give a value with it ...

<%
function Auth(variable1)
asp stuff
end function
%>

<a href... onClick=&quot;Auth('test')&quot;>the link</a>

is something like this possible? The One And Only KryptoS
 
you can't do this. Either you need to perform the function with client side scripting or run a .asp such as a form submission does. ASP being server side cannot interate with the browser as I think you may be trying to do here. A good combination of javascript and ASP can always perform the the tasks needed. You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
It's for my website. In the left-frame I have a menu with links to the pages. And I want a visiter-counter for everypage. So I thought , maybe I can count everytime someone clicks on a link. Somebody an idea how I can do that? It must been done with <a href..></a>, and if possible without a form

greetz The One And Only KryptoS
 
There are quite a few qays to do this. Most of them depend on where you are keeping the counter value. Pretend it is somewhere accessible for now. You could still do this in several ways.

Link Click Counter:
You could increment each time someone clicks a link (which would not be visitor count, but rather click count for your site). If you really want to count clicks, write a short javascript function in your left frame that will direct the left side to the menu page and the right side to the target page. Like:

Code:
function myLittleRedirect(targetAddr){
   window.location=&quot;menu.asp?action=increment&quot;;
   window.parent.frames(1).location=targetAddr;
}

Then in your menu, which is an asp file now, you read the value of Request.QueryString(&quot;action&quot;) everytime, and if it is = &quot;increment&quot; you increment your counter before displaying the rest of your page.
One warning, the above javascript was only enough to give you the general idea, I will almost gaurantee that it weon't work as I wrote it off the top of my head and haven't used javascript in quite a few months.

Session Counter:
Very easy, simply increment your counter in Session OnStart.

Db Driven, never count 'em twice
Heh, a bit more difficult, to display your counter you will simply do a count on the pretend table we created called visitor. This table will have 1 field which will be a primary/unique field, IP Address. Everytime someone hits your front page you attempt to insert their ip address into the table, ignore errors. Then do a count(*) on that table, you can then display the number of unique places that have hit your site, I say places because with an ip detection everyone visiting from behind one firewall will look the same. Plus no one gets counted twice unless they move to a differant place.

Lots and lots of ways to do this, saved as application variables, db variables, text data in a txt file...

Hope you at least get some ideas here.
-Tarwn
------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top