Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Jeffrey Valeroso 40 posts 101 karma points
    Aug 18, 2012 @ 11:22
    Jeffrey Valeroso

    How to call increment method on click and not in page load?

    Ex. I have an xslt that lists the download items and I want to increment the download counter once download button is clicked

    <xsl:for-each select="$currentPage//">

    <xsl:variable name="incement" select="ViewCount:Increment(number(@id), 'Download')"/>
    <xsl:variable name="counter" select="ViewCount:GetViews(number(@id),'Download')" /> 
    xsl:value-of select="downloadItem1"/>...
    <button onclick="{$incement}">Download</button>
     <xsl:value-of select="$counter//@count" /> 

    //list all download items


    The problem is everytime I click download, all the dowload items increment by 1....supposedly only the item with has this certain ID should be incremented.



  • Robert Foster 424 posts 1626 karma points MVP admin c-trib
    Aug 18, 2012 @ 11:59
    Robert Foster

    Hi Jeffrey,

    By setting the value of increment to ViewCount:Increment(number(@id), 'Download') you are incrementing the counter for that id as soon as you assign the variable (which is incidentally going to end up as null or '')...

    Currently it looks like your code will just render as <button onclick="">Download</button>

    If you want to increment a view counter when you download something, then you would need to set up some sort of server side script that you can post to that does the increment and then initiates the download.

    Hope this helps,


Please Sign in or register to post replies

Write your reply to: