javascript - Getting "Uncaught SyntaxError: Unexpected token ;" error while using for loop -


here have loop iterator on html elements in jsf application.

        var tmp = document.getelementsbytagname("input");         var counter = 0;         var arr = new array();         (var = 0; i<tmp.length; i++) {             if (tmp[i].parentnode.nodename === "td" && tmp[i].getattribute("type") !== "submit") {                 arr[counter] = tmp[i];                 counter++;             }         } 

this loop inside script tag:

<script type="text/javascript"> <!--          //--> </script> 

when load page in web browser following error(shown in google chrome developer tools)

enter image description here enter image description here

as can see in screenshot, script in html page has &lt; should have <. syntax error. generating page templating language "escapes" html code? cause problem.

one solution put javascript code in separate .js file. should avoid escaping , leave code unchanged.

if need have inline javascript right there in html page, templating languages have way turn off escaping specific piece of text.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -