Essentially I need to specify a JQuery variable in my webpage's body tag, and have a function in my head tag read it. This is the function in my head tag (simplified):
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($) {
$('a.paymentAdd').click(function(){
alert ("rowCount 1 = " + rowCount);
rowCount++;
});
});
</script>
And this in my body tag:
<script type="text/javascript">
jQuery(document).ready(function($) {
var rowCount = 3;
alert ("rowCount 2 = " + rowCount);
});
</script>
(I have to specify the variable in my body tag because it is generated by PHP which is only available in that part of my template.)
When the page loads I get the alert "rowCount 2 = 3" (correct)
When I click a link with class "paymentAdd" I get the alert "rowCount 1 = undefined" (incorrect- expecting 3?)