搜索Javascript函数未定义

时间:2016-02-28 23:57:06

标签: javascript html

搜索功能一直给我

未捕获的ReferenceError:未定义finddesiredspot @click @(index):268

我尝试了所有东西,甚至将脚本从头到脚移动都无效。有什么想法吗?

这是javascript

var panos = [
              {% for group in project.panoGroups %}{% for pano in group.panos %}
        { id:"{{pano.tourId}}" , name:"{{pano.description.name}}", description:"{{pano.description.description|striphtmltags}}", thumb:"./{{dataDirectory}}/{{pano.thumbnailPath}}" },
              {% endfor %}{% endfor %}
            ];
            function resetsearch() {
                document.getElementById('resultDiv').style.display = "none";
                document.getElementById('texttosearch').innerHTML = "";
            }
function finddesiredspot() {
                if (texttosearch.value == "")
                {
                    alert("Empty string");
                    return;
                }
                var found = false;
                var foundpanos = [];
                for (i = 0; i < panos.length; i++) {
                        if (kindofsearch.value == "name")
                        {
                            if (panos[i].name.toLowerCase().indexOf(texttosearch.value.toLowerCase()) > -1)
                            {
                                found = true;
                                foundpanos.push(panos[i]);
                            }
                        }
                        if (kindofsearch.value == "description")
                        {
                            if (panos[i].description.toLowerCase().indexOf(texttosearch.value.toLowerCase()) > -1)
                            {
                                found = true;
                                foundpanos.push(panos[i]);
                            }
                        }
                }
                if (found)
                {
                    if (foundpanos.length == 1)
                    {
                        document.getElementById('resultDiv').style.display = "none";

                        var callstr = "mainloadscene(" + foundpanos[0].id + ")";
                        getTemplateTourPlayer().call(callstr);
                        callstr = "looktohotspot(" + foundpanos[0].id + ")";
                        getTemplateTourPlayer().call(callstr);
                    }
                    else
                    {
                        document.getElementById('resultDiv').style.display = "block";

                        var resultsStr = "<div class='list-group'>";
                        for (i = 0 ; i < foundpanos.length ; i++)
                        {
                            resultsStr += "<a href='#' class='list-group-item' onclick=\"getTemplateTourPlayer().call('mainloadscene(" + foundpanos[i].id + ")');\"><img class='list-item-thumb' src=\""+ foundpanos[i].thumb + "\"/><strong>" + foundpanos[i].name + "</strong>";
                        }
                        resultsStr += "</ul>";
                        document.getElementById('resultList').innerHTML = resultsStr;
                    }
                }
                else
                {
                        document.getElementById('resultDiv').style.display = "block";
                        document.getElementById('resultList').innerHTML = "No Result found";
                }
            }

这是HTML

<div class="input-group">
<input type="text" id="texttosearch" class="form-control" placeholder="Text to search">
<span class="input-group-btn">
<button id="searchbutton" type="button" onclick="finddesiredspot()" class="btn btn-primary">Search</button>
</span>
</div>

0 个答案:

没有答案