I have a javascript code in my xhtml file. Here it is:
<h:head>
<h:outputStylesheet library="css" name="styles.css" />
<script>
function dataTableSelectOneRadio(radio) {
var id = radio.name.substring(radio.name.lastIndexOf(':'));
var el = radio.form.elements;
for (var i = 0; i < el.length; i++) {
if (el[i].name.substring(el[i].name.lastIndexOf(':')) == id) {
el[i].checked = false;
}
}
radio.checked = true;
}
</script>
</h:head>
The problem ist, inside the for loop it gives error for "<" operator saying that "The content of elements must consist of well-formed character data or markup.". I think it sees "<" as an html element i.e. "body, html etc. but i am not sure. How can i fix this?
Thanks
Edit: I now tried this but still an error. Is there a syntax error you see?
<script>
function dataTableSelectOneRadio(radio) {
var id = radio.name.substring(radio.name.lastIndexOf(':'));
var el = radio.form.elements;
for (var i = 0; i < el.length; i++) {
if (el[i].name.substring(el[i].name.lastIndexOf(':')) == id) {
el[i].checked = false;
}
}
radio.checked = true;
}
</script>
The error says that:
myaccounts.xhtml:5:52 Expected ) but found ;
for (var i = 0; i < el.length; i++) {
^
myaccounts.xhtml:5:57 Expected ; but found )
for (var i = 0; i < el.length; i++) {
^