Copy link to clipboard
Copied
I want to set a varaible on a button click. I have been trying this:
<a href="##" onclick="document.getElementById('faq1').style.display='block';
document.getElementById('faq2').style.display='none';
document.getElementById('faq3').style.display='none';
<cfset pageCount = pageCount + 1>">
<span class="contentHeader">Overview</span>
</a>
This does not seem to work. Does anyone have any ideas how to make this work? Thanks
Copy link to clipboard
Copied
It's not clear what you are attempting. The only variable I see is pageCount but I don't see anywhere where you are attempting to display it.
Copy link to clipboard
Copied
I am not trying to display it. I am keeping track of it and once it reaches three a button appears on the screen.
Copy link to clipboard
Copied
You are trying to set a ColdFusion (server side) variable using Javascript (client side). You cannot run ColdFusion code in the browser. If you look at the source, you will see that your <cfset ... /> is not passed along to the browser.
You could call an ajax request which would execute CF code on the server to increase the count and store it in the user's session, for example, but I think you need to go back to the basics and understand the difference between client side code and server side.
Copy link to clipboard
Copied
TheScarecrow wrote:
I want to set a varaible on a button click. I have been trying this:
<a href="##" onclick="document.getElementById('faq1').style.display='block';
document.getElementById('faq2').style.display='none';
document.getElementById('faq3').style.display='none';
<cfset pageCount = pageCount + 1>">
<span class="contentHeader">Overview</span>
</a>
This does not seem to work. Does anyone have any ideas how to make this work? Thanks
I see no button. I see no variable that needs setting either. Could you explain a bit more?