</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.
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.
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.
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.
is working on a reply...