n8w Posted December 13, 2006 Share Posted December 13, 2006 objective: I want to track outbound links using the event [b]onclick[/b]currently, I am doing using a form that goes to a script called go.php .. it looks up the id in the database and then goes .. but I would like to avoid forms so search engines can follow the links.Here is the current codenote:name="user_id" is the id of the outbound linkname="token" is a variable that is compared to a session variable to make sure the outbound link being counted is originating at my website[code]<form action="go.php" method="post" name="frmMyForm1297" target="_blank"><a href="JavaScript:document.frmMyForm1297.submit();" ><img src="../../images/illustrators/1297.jpg" alt="Catherine Lepage" width="190" height="190" border="0" /><br /><span class="headlines"><strong> Catherine Lepage</strong></span></a><input type="hidden" value="1297" name="user_id" ><input type="hidden" value="b3a4156b1249469af356e6bfa0483f74" name="token" ></form>[/code]Ideally, I would like it to be like the following .. but I am not sure how to get it to work[code]<form action="go.php" method="post" name="frmMyForm1297" target="_blank"><a href="http://www.theurl.com" onclick="outbound(1297,b3a4156b1249469af356e6bfa0483f74)"><img src="../../images/illustrators/1297.jpg" alt="Catherine Lepage" width="190" height="190" border="0" /><br /><span class="headlines"><strong> Catherine Lepage</strong></span></a>[/code] Link to comment https://forums.phpfreaks.com/topic/30551-call-a-php-from-onclick-event/ Share on other sites More sharing options...
joquius Posted December 13, 2006 Share Posted December 13, 2006 can't you just set the page to direct to go.php?name=soandso&otherstuff=blah and just input it from some fields or data on the page? (inputting the values with javascript of course) Link to comment https://forums.phpfreaks.com/topic/30551-call-a-php-from-onclick-event/#findComment-140638 Share on other sites More sharing options...
n8w Posted December 13, 2006 Author Share Posted December 13, 2006 no cause I want to avoid calling the go.php script using href .. I'd like the href to go to the url and the onclick to count the outbound link by calling the go.phpalso I want to avoid using the get method cause people can easily manipulate the query string .. hence I am using the post method right now Link to comment https://forums.phpfreaks.com/topic/30551-call-a-php-from-onclick-event/#findComment-140645 Share on other sites More sharing options...
kenrbnsn Posted December 13, 2006 Share Posted December 13, 2006 The only way to "call" a PHP routine from Javascript is to use AJAX techniques.Ken Link to comment https://forums.phpfreaks.com/topic/30551-call-a-php-from-onclick-event/#findComment-140647 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.