When adding the javascript code to the document.bplt file - the following two solutions will work:
1) escape all as CDATA section
<script>
<![CDATA[
var i;
for (i = 0; i < dropdown.length; i++) {
}
]]>
</script>
2) encode any xml special character :
<script>
var i;
for (i = 0; i < dropdown.length; i++) {
}
</script>