Answered
Coldfusion 2018 compiler
Within a cfm, I have a script section and the pre-compiler is throwing this error - it is not recognixing that $("#selectname") is valid invalid token at the second ". Any ideas on how to go around the problem?


Within a cfm, I have a script section and the pre-compiler is throwing this error - it is not recognixing that $("#selectname") is valid invalid token at the second ". Any ideas on how to go around the problem?


If the Javascript is not part of CF code, then use single #.
If the Javascript is part of CF code (for example, within cfoutput tags), then use ## instead of #.
testPage1.cfm
<!---
If Javascript is not part of CF code, then use single #
--->
<script type="text/javascript" language="Javascript">
$( function(){
$("#selectname").autocomplete({
source: arrNames,
select: function(event, ui) {
$("#selectedname").val(ui.item.value);
},
});
});
</script>
testPage2.cfm
<!---
If Javascript is part of CF code (for example,
within cfoutput tags), then use ##
--->
<cfoutput>
<script type="text/javascript" language="Javascript">
$( function(){
$("##selectname").autocomplete({
source: arrNames,
select: function(event, ui) {
$("##selectedname").val(ui.item.value);
},
});
});
</script>
</cfoutput>
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.