title: Using Onclick on an HREF tag in Coldfusion
body: <p>I was wondering if someone can tell me what is wrong with this code because it doesn't work and it does not give me any errors either.</p>
  
  <p>With this code I am trying to access a component that updates a DB table each time someone press on the link.</p>
  
  <pre><code>&lt;cfajaxproxy bind="url:http://www.example.com/admin/CRM/linktracking.cfc" /&gt;
  &lt;cfscript&gt;
      SSLtype = (CGI.HTTPS EQ 'off')?'http://':'https://';
  &lt;/cfscript&gt;
  
  &lt;cfset domainname = CGI.SERVER_NAME&gt;
  &lt;cfset domainURL = SSLtype&amp;CGI.SERVER_NAME&amp;CGI.SCRIPT_NAME&amp;'?'&amp;CGI.QUERY_STRING&gt;
  
      &lt;script&gt;    
          function insertTracking(href) {
          var instance = new ajaxjsclass();
          instance.setCallbackHandler();
          &lt;cfoutput&gt;
              instance.insertTrack(href,'#surveymain.contactid#','#domainname#','#domainURL#');
          &lt;/cfoutput&gt;
          }       
      &lt;/script&gt; 
  </code></pre>
  
  <p>This is the component I am trying to access.</p>
  
  <pre><code>&lt;cfcomponent&gt;
  
  &lt;cffunction name="insertTrack" access="remote" returntype="void" &gt;
  &lt;cfargument name="clickedURL" required="yes"&gt;
  &lt;cfargument name="contactid" required="yes"&gt;
  &lt;cfargument name="domainName" required="yes"&gt;
  &lt;cfargument name="domainURL" required="yes"&gt;
  
  &lt;cfquery name="q_inserttrack" datasource="dpsigweb"&gt;
  update survey_tracking
  set surveystarted = &lt;cfqueryparam value="#now()#" cfsqltype="CF_SQL_TIMESTAMP"&gt;
  where contactid= '#contactid#'
  &lt;/cfquery&gt;
  
  
  &lt;cfif ARGUMENTS.contactid NEQ ''&gt;
      &lt;cfscript&gt;
          additionalInfo = '&lt;b&gt;Clicked URL&lt;/b&gt; - &lt;i&gt;#ARGUMENTS.clickedURL#&lt;/i&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;From Site&lt;/b&gt; - &lt;i&gt;#ARGUMENTS.domainURL#&lt;/i&gt;';
          gaCFC = CreateObject("component","mod_sigweb.components.guestaccount");
          gaCFC.AddCorrespondenceCurDoctorProcedureRemote(
              functionPassword = 'password',
              contactid = '#ARGUMENTS.contactid#',
              theMessage = additionalInfo,
              statustype = 'Survey Started',
              contactresult ='Survey Started'
              );
      &lt;/cfscript&gt;
  &lt;/cfif&gt;
  
  &lt;/cffunction&gt;
  &lt;/cfcomponent&gt;  
  </code></pre>
  
  <p>This is where I am trying to access the function from:</p>
  
  <pre><code>&lt;a href="http://dev.example.com/surveys/survey.cfm?id=#id#&amp;contactid=#contactid#&amp;doctorid=#doctorid#" onClick="insertTracking(this.href)" &gt;
  </code></pre>
  
  <p>I am suspecting that my <code>&lt;cfajaxproxy&gt;</code> tag may have a syntax error but when I am pressing the link I am not getting any errors.</p>
  
  <p>I change my <code>cfajaxproxy</code> to this</p>
  
  <pre><code>&lt;cfajaxproxy cfc="linktracking" jsclassname="ajaxjsclass"  /&gt;
  </code></pre>
  
  <p>but still the function does not seem to work. I even moved the component and the cfm file in the same folder but it still doesn't work.</p>
  
  <p>Edit:
  I forgot to mention that i am sending this code in an email template. i don't know if that matters in any way. I created a test page that I am testing locally and my code works just fine. If there is something that I need to change because of that please let me know</p>