Basically, the method prints a list with values and when I click on a value, I get this error : Uncaught SyntaxError: Unexpected identifier on line 6.
As a result,I am unable to pass the value that I click on,onto the liveSearch method. I have tried searching the net in hopes of solving the error but to no avail,I couldn't find a solution. Please advise.
function printSuggestResult(arrOfSuggestText,getRows){
var htmlStr = "<button id='dropdownB' href='#' class='dropdown-toggle btn btn-default'data-toggle='dropdown'>Found <span id='resultCount' class='badge'></span>  </b></button><ul class='list-group scrollable-menu'>";
for(var i=0; i<arrOfSuggestText.length; i++){
htmlStr += "<li class='list-group-item '>";
if(arrOfSuggestText[i] != "null"){
htmlStr += '<a id="searchResult'+i+'" href="javascript:liveSearch('+arrOfSuggestText[i]+')" > '+arrOfSuggestText[i]+'</a>';
}
htmlStr += "</li>";
}
htmlStr += "</ul>";
document.getElementById('searchResultList').innerHTML = htmlStr;
$('#resultCount').text(getRows);
}
function liveSearch(getText){
var arrOfText = new Array();
var arrOfLat = new Array();
var arrOfLon = new Array();
getText = getText.replace(" ","+");
var testy = encodeURIComponent(getText);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…