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
    0

    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

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

    <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" /> 

    </li>
    //list all download items
    <xsl:for-each>
    </ul>

     

    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 459 posts 1820 karma points MVP 2x admin c-trib
    Aug 18, 2012 @ 11:59
    Robert Foster
    2

    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,

    Rob.

Please Sign in or register to post replies

Write your reply to:

Draft