Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Location
    CPU
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation jquery serialize question

    hi all this is my 1st post

    I am lil new to jquery so I have some question

    I success fully did a php ajax search using jquery here is a screen shot


    The problem is I couldnt serizlize the check box which are generated after searching ? how to do that please share your ideas with me
    --
    tx

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    It's a bit hard to debug a screenshot

    Can you post the code you've got?

    Generally you'd call serialize() on the form object.

  • #3
    New to the CF scene
    Join Date
    Feb 2010
    Location
    CPU
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts





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




    index.html


    Code:
    <!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> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
    <title>Untitled Document</title> 
            <script src="js/jquery-1.3.2.min.js"></script> 
            <script src="js/controller.js"></script> 
    
    </head>
    
    <body> 
    <form> 
    <input name="searchbox" type="text" id="searchbox" /> 
            <a class="button" id="submitbutton" href="#"><span id="buttontext">Search</span></a> 
    </form> 
    <div id="resultsContainer"></div> 
    <tt id="rec"></tt> 
    </body> 
    </html>

    --------------------------------------------------------------------------------

    Code:
    control.js
    
    $(document).ready(function() { 
       $("#submitbutton").click(function(){    
    
            if($("#searchbox").attr('value')!=""){ 
                getResults(); 
            } 
        }); 
        function getResults() 
        { 
            $.get("search.php",{stext: $("#searchbox").val(), type: "results"}, function(data){ 
                   $("#resultsContainer").html(data); 
                $("#resultsContainer").show("blind"); 
            }); 
        } 
         $("form").submit(function () { return false; }); 
        
    
         function showValues() { 
             var str = $("form").serialize(); 
              $("#rec").text(str); 
        } 
        $(":checkbox, :radio").click(showValues); 
        $("select").change(showValues); 
    
    
    });
    --------------------------------------------------------------------------------

    php search


    PHP Code:
    <?php 
    $objConn
    =new Control(); 
    $type=''
    $search ''

    if(isset(
    $_GET['stext'])) 


         
    $search $_GET['stext']; 

         
    $type$_GET['type']; 


    else 



        
    $search ""

    }

    if(
    $type == "results"

        
    $result=$objConn->get_search($search); 
            
    $idx=''
            while(
    $arraymysql_fetch_array($result)) 

            { 
                
    $idx=$array['id']; 
                echo 
    "<input type='checkbox' name='checkbox' value='0' id='$idx'/>"
                echo 
    $idx."<br>"
            } 
    }

  • #4
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    The checkboxes aren't being written inside a form. You've got a closing form tag, then your resultsContainer div.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •