jquery serizlize probilem with checkboxes

jquery serizlize probilem with checkboxes

I am developing a simple search and select using php and jquery but after generating the results








I couldn't get the serialized values from checkbox please help me to figure out the problem




index.html

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Untitled Document</title>
  6.         <script src="js/jquery-1.3.2.min.js"></script>
  7.         <script src="js/controller.js"></script>
  8. </head>
  9. <body>
  10. <form>
  11. <input name="searchbox" type="text" id="searchbox" />
  12.         <a class="button" id="submitbutton" href="#"><span id="buttontext">Search</span></a>
  13. </form>
  14. <div id="resultsContainer"></div>
  15. <tt id="rec"></tt>
  16. </body>
  17. </html>




control.js
  1. $(document).ready(function() {
  2.    $("#submitbutton").click(function(){   
  3.         if($("#searchbox").attr('value')!=""){
  4.             getResults();
  5.         }
  6.     });
  7.     function getResults()
  8.     {
  9.         $.get("search.php",{stext: $("#searchbox").val(), type: "results"}, function(data){
  10.                $("#resultsContainer").html(data);
  11.             $("#resultsContainer").show("blind");
  12.         });
  13.     }
  14.      $("form").submit(function () { return false; });
  15.    
  16.      function showValues() {
  17.          var str = $("form").serialize();
  18.           $("#rec").text(str);
  19.     }
  20.     $(":checkbox, :radio").click(showValues);
  21.     $("select").change(showValues);

  22. });


php search

  1. <?php
  2. $objConn=new Control();
  3. $type='';
  4. $search = '';
  5. if(isset($_GET['stext']))
  6. {
  7.      $search = $_GET['stext'];
  8.      $type= $_GET['type'];
  9. }
  10. else
  11. {
  12.     $search = "";
  13. }
  14. if($type == "results")
  15. {
  16.     $result=$objConn->get_search($search);
  17.         $idx='';
  18.         while($array= mysql_fetch_array($result))
  19.         {
  20.             $idx=$array['id'];
  21.             echo "<input type='checkbox' name='checkbox' value='0' id='$idx'/>";
  22.             echo $idx."<br>";
  23.         }
  24. }