I have updated this to reflect the real issue. For some reason, as described below, the JavaScript runtime on my system (2019 r2) refuses to save code that includes a 'for statement' in the form 'for (i=0; i < 5; i++) ... '. Testing the code on http://www.jslint.com/ reports the 'for' as invalid and I assume it has been deprecated. I used 'array.forEach' which solved my issue, however it turns out that the real problem was that I used Flares internal editor to create my XML - if I had used the "Insert>Script" command it would have added the requisite CDATA constricts around the code. See viewtopic.php?f=6&t=31272&p=135647&hilit=CDATA#p135647 for details. Thanks!
I have a page with a number of checkboxes and I have added the following JavaScript to the body, the aim being to fill the 'SelectorControls' array so that in my event handler I can use the selected controls name to determine the control index which will then be used to set/clear the state of the control in the 'SelectorState' array. My problem is that when I try to save the topic the Flare editor says that the "Document is invalid". If I remove the for loop it is saves. I have tried various simple numeric for constructs with the same result and I assume I misunderstand something. The code follows and I'd appreciate any help on this.
var SelectorControls = [];
var SelectorState = [];
var i = 0;
<script>
SelectorControls = document.getElementsByTagName("input");
// the next fails to save
for (i = 0; i < SelectorControls.length; i++) {
SelectorState.push("false");
}
</script>
Topic with Javascript is invalid - corrected!
-
- Jr. Propeller Head
- Posts: 4
- Joined: Mon Sep 17, 2012 4:01 am
- Location: Melbourne, Australia