控件的名称麻烦写上注释~多谢

解决方案 »

  1.   

    查询textbox里的内容!textbox 有很多内容吗?需要查询吗?通常查询是,根据textbox里的内容 查询数据库!这个不是javascript能做的。需要服务器端程序
      

  2.   


    就是在textbox里输入编号点击查询按钮,然后查询在xml里的数据,不走数据库的。
      

  3.   

    1.建立一个demo.html, 注意你得包含jquery的js文件(没有的话, 网上搜索了自己下)<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>无标题页</title>
        <script src="jquery-1.4.4.js" type="text/javascript"></script>
        <script type="text/javascript">
            function search() {
                var searchStrLow = $("#txtTitle").val().toLowerCase();
                $.get("1.xml", function(data) {
                    var html = "";
                    $(data).find('book').each(function() {
                        var titleLow = $(this).find("title").text().toLowerCase();
                        if (titleLow.indexOf(searchStrLow)!=-1) {
                            html += "<tr><td>" + $(this).find("title").text() + "</td>";
                            html += "<td>" + $(this).find("author").text() + "</td>";
                            html += "<td>" + $(this).find("year").text() + "</td></tr>";
                            $("#tbody1").html(html);
                        }
                    });
                });
            }
        </script>
    </head>
    <body>
        <span>输入标题:</span><input id="txtTitle" type="text" />
        <input id="Button1" type="button" value="搜索" onclick="search()" />
        <table style="width: 100%;">
            <thead><tr><td>Title</td><td>Author</td><td>Year</td></tr></thead>
            <tbody id="tbody1">
            </tbody>
        </table>
    </body>
    </html>2.建立一个1.xml<?xml version="1.0" encoding="utf-8" ?>
    <bookstore>
      <book id="No1">
      <title>An Introduction to XML</title>
      <author>Chunbin</author>
      <year>2010</year>
      <price>98.0</price>
      
    </book>
      <book id="No2">
      <title>The Performance of DataBase</title>
      <author>John</author>
      <year>1996</year>
      <price>56.0</price>
    </book>
    </bookstore>
      

  4.   

    楼上的方法是对的,用ajax获取xml,再进行操作。