Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
108
rated 0 times [  115] [ 7]  / answers: 1 / hits: 17442  / 13 Years ago, sun, january 8, 2012, 12:00:00

hello im am getting JS error :



 Uncaught SyntaxError: Unexpected identifier


here



<script type=text/javascript>
var cur_level = 1;
var ids_arr = new Array(<?php echo $max_level?>);
var im_here = new Array(<?php echo $max_level?>);
ids_arr[0] = 1;
im_here[0] = |;
function displayData(id, level, used, title)
{
if(used){
choice = document.getElementById('divv'+id).innerHTML;
document.getElementById('test_div').innerHTML = choice;

} else {
document.getElementById('test_div').innerHTML = ' No lerning paths to show.';
updateLinksDiv(id, level, title);

}
}

function updateLinksDiv(id, level, title)
{
var links_div_info = document.getElementById('links_parent_'+id);
var tmpHTML = '';
var here = '';

for(i=0;i<level;i++){
here+= '->'+im_here[i];
links_div_info = document.getElementById('links_parent_'+ids_arr[i]);
tmpHTML += '<div id=divl_'+links_div_info.id+'>'+links_div_info.innerHTML+'</div>';
}
links_div_info = document.getElementById('links_parent_'+id);
tmpHTML += '<div id=divl_'+links_div_info.id+'>'+links_div_info.innerHTML+'</div>';

document.getElementById('links').innerHTML = tmpHTML;
ids_arr[i] = id;
im_here[i] = title;
}

</script>


<script type=text/javascript>
window.onload=updateLinksDiv(1 , 0 , | ) ;
</script>


the functions are suppose to create an expanding that opens up with levels and everything was working fine untill i added the title and i started getting the error.
the error points me to the last and i just cant find the error...
i try to call displayData like this



onclick=displayData('.$cat->id.','.$cat->level.',0,'.$cat->title.')


any suggestions for what i'm not seeing.?



thank you


More From » function

 Answers
10

In your comment you say that displayData(26,1,0,כיתה ג) is generated. This explains the symptoms, as here the last parameter contains a space in addition to Hebrew letters, so the JavaScript intepreter sees it as two identifiers separated by a space, and the identifiers are probably undefined. Google Chrome gives the error message you describe, whereas Firefox and IE say, more enigmatically, “missing ) after argument list.”



Apparently the generated code is supposed to have the last parameter in quotation marks, i.e. 'כיתה ג'. You need to modify the generation to contain them.


[#88160] Friday, January 6, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
josh

Total Points: 391
Total Questions: 112
Total Answers: 90

Location: Aruba
Member since Fri, Jun 24, 2022
2 Years ago
;