Uncaught SyntaxError: '#' not followed by identifier
In a contribution page, I get an Uncaught SyntaxError: '#' not followed by identifier
error in the console.
Reproduction steps
- Create a contribution page.
- Insert it in a WordPress page.
- Display the page.
- Open the console of the navigator
In templates/CRM/Contribute/Form/Contribution/Main.tpl, the following lines are misinterpreted before being output:
function useAmountOther() {
var priceset = {/literal}
{if $contriPriceset}'{$contriPriceset}'
{else}0
{/if}
{literal};
for (i = 0; i < document.Main.elements.length; i++) {
element = document.Main.elements[i];
if (element.type == 'radio' && element.name == priceset) {
if (element.value == '0') {
element.click();
} else {
element.checked = false;
}
}
}
}
In the source of the generated page:
function useAmountOther() {
var priceset =
0
;
for (i = 0; i < document.Main.elements.length; i++) {
element = document.Main.elements[i];
if (element.type == 'radio' && element.name == priceset) {
if (element.value == '0') {
element.click();
} else {
element.checked = false;
}
}
}
}
Environment information
- Browser: Firefox 112
- CiviCRM: 5.61.2
- PHP: 8.0
- CMS: WordPress 6.2
- Database: MariaDB 10.5
- Web Server: Apache 2.4