English 中文(简体)
我怎么能够用我的超文本和PHP来执行这份联合材料法典?
原标题:How can I implement this JS code in my HTML and PHP?

我发现这一联合材料功能,如谷歌即刻,它只是通过搜索和展示在布顿DIV名称中搜索的结果。

The JS Code is:

$(function() { 
  var theTable = $( table.food_planner )

  theTable.find("tbody > tr").find("td:eq(1)").mousedown(function(){
    $(this).prev().find(":checkbox").click()
  });

  $("#filter").keyup(function() {
    $.uiTableFilter( theTable, this.value );
  })

  $( #filter-form ).submit(function(){
    theTable.find("tbody > tr:visible > td:eq(1)").mousedown();
    return false;
  }).focus(); //Give focus to input field
});  

我的超文本照此办理:

<body>
  <div class="main">
    <form method="get" action="quiz.php" id="form">

      <p class="subFont">Search Quizzes</p>
      <input type="text" id="search" name="search"/><br>

      <button type="submit[]" class="quizBlock" name="button"  id="quizID" action="quiz.php" method="get" value="<?php echo $quiz[$i][ ID ]?>">
        <p><?php echo $quiz[$i][ Name ]?></p>
      </button>

   </form>
  </div>
</body>

对这种形式而言,略微多一点,一些购买力平价。 公共卫生和社会福利部使用一种 lo和打印机,其中有多少纽芬兰人有数据,每个州都有不同价值,需要寻找不同的内容。

我知道基本购买力平价和超文本,但几乎没有任何联合材料,我通过W3图:p

我怎么能够改变我的超文本和联合材料法,以便它们共同工作?

我感谢事先作出的任何答复!

问题回答

你需要把文字添加到你的网页上,这样:

<script type="text/javascript">
  // Your script goes here
</script>

Besides that (and before that, in the HTML page!), you should include the JQuery library, because it is used by your script. You can download JQuery to your own server and link it there, but you may benefit from including JQuery from Google.

Optionally, you can put your script in a separate file to, and link it in your page. Since you don t have to do any actual Javascript programming, I think someone with knowledge of PHP and html should be able to include a script in their page.

如果你想问server <>em>供参考,并立即出现在网页上,you应当使用AJRP(Asynchronous Javascript and XML Request)办法。 以下是如何做到这一点的简单例子。 你们应当认识到,这是一个简单的例子,旨在说明这项工作如何,但不一定是最佳做法的范例。

html的标记可能与下列内容相似:

<html>
    <head>
        <title>Instant Search</title>
        <script type=”text/javascript” src=”../jquery.js”></script>
        <script type="text/javascript">
            var runningRequest = false;
            var request;

            //Identify the typing action
            $( input#q ).keyup(function(e){
                e.preventDefault();
                var $q = $(this);

                if($q.val() ==   ){
                    $( div#results ).html(  );
                    return false;
                }

                //Abort opened requests to speed it up
                if(runningRequest){
                    request.abort();
                }

                runningRequest=true;
                request = $.getJSON( search.php ,{
                    q:$q.val()
                },function(data){           
                   showResults(data,$q.val());
                   runningRequest=false;
                });

                //Create HTML structure for the results and insert it on the result div
                function showResults(data, highlight){
                    var resultHtml =   ;
                    $.each(data, function(i,item){
                    resultHtml+= <div class="result"> ;
                    resultHtml+= <h2><a href="#"> +item.title+ </a></h2> ;
                    resultHtml+= <p> +item.post.replace(highlight,  <span class="highlight"> +highlight+ </span> )+ </p> ;
                    resultHtml+= <a href="#" class="readMore">Read more..</a> 
                    resultHtml+= </div> ;
                });

                $( div#results ).html(resultHtml);
            }

            $( form ).submit(function(e){
                e.preventDefault();
            });
        });
    </script>
    </head>
    <body>

        //Form
        <form method=”get” action=”">
            <input type=”text” id=”q” name=”q” />
            <input type=”submit” value=”Search” />
        </form>

       //Result’s Container
       <div id=”results”></div>

    </body>
</html>

c:

  form{
      margin:15px;
      padding:5px;
      border-bottom:1px solid #ddd;
  }

  form input[type=submit]{display:none;}

  div#results{
      padding:10px 0px 0px 15px;
  }

  div#results div.result{
      padding:10px 0px;
      margin:10px 0px 10px;
  }

  div#results div.result a.readMore{color:green;}

  div#results div.result h2{
      font-size:19px;
      margin:0px 0px 5px;
      padding:0px;
      color:#1111CC;
      font-weight:normal;
  }

  div#results div.result h2 a{
      text-decoration:none;
      border-bottom:1px solid #1111cc;
  }

  div#results div.result p{
      margin:0;
      padding:0;
  }

  span.highlight{
      background:#FCFFA3;
      padding:3px;
      font-weight:bold;
  } 

PHP服务器边代码:

<?php if(!empty($_GET[ q ])) {
    search();
}

function search() {
    $con = mysql_connect( localhost , root ,   );
    mysql_select_db( mydb , $con);

    $q = mysql_real_escape_string($_GET[ q ], $con);
    $sql = mysql_query("
        SELECT
        p.title, SUBSTR(p.post,1,300) as post
        FROM Posts p
        WHERE p.title LIKE  %{$q}%  OR p.post LIKE  %{$q}% 
    ");

    //Create an array with the results
    $results=array();
    while($v = mysql_fetch_object($sql)){
        $results[] = array(
             title =>$v->title,
             post =>$v->post
        );
    }

    //using JSON to encode the array
    echo json_encode($results);
}

原件来源:





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!