SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: ajax/jquery

  1. #1
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ajax/jquery

    I'm trying to acquire names from a database table and insert them into boxes in a form which will in turn do an insertion into another database table. Thus far I get them into the input box but when I click the submit, I get an
    error:
    Code:
    Query failed: Column count doesn't match value count at row 1.
    I know that the table jives with the code and having never used Ajax I just don't know.
    PHP Code:
    <?php
    include 'prerentget.php';
    ?>
    HTML Code:
    <html>
    <head>
        <style type="text/css">
            </style>
    <script type="text/javascript" 
    
    src="http://ajax.googleapis.com/ajax/libs/jquery/
    
    1.4.2/jquery.min.js"></script>
        <script type="text/javascript">
            function getResults() {
                
                var search_val = $("#apt").val();
                $.post("test.php", { search_term: 
    
    search_val }, function(data) {
                    
                    if (data.length > 0) {
                        $("#tname")[0].value = data;
                    }
                })
            } 
            
        </script>
    
    <script type="text/javascript">
    window.google_analytics_uacct = 
    
    "UA-256751-2";
    </script>
    
    </head>
    <body onload="document.form.apt.focus()">
    <form name=form action="testinsert.php" 
    
    method="post">
    <input type="text" size="2" name="apt" id="apt" 
    
    onkeyup="getResults();
    "if(this.value.length==this.size)document.form.ti
    
    me.focus();" />Apt<br />
    <input type="text" size="25" id="tname" 
    
    />Name<br />
    
    <INPUT TYPE="text" size=10 
    
    name=datereceived  
    onKeyUp="if(this.value.length==this.size)docum
    
    ent.form.time.focus();">Date Received<BR>
     
    <INPUT TYPE="text" size=7 name=time>Time 
    
    Received<BR> 
    <INPUT TYPE="text" size=100 
    
    name=symptom>Problem<BR> 
    <INPUT TYPE="text" size=100 
    
    name=action>Action<BR>
     
    <INPUT TYPE="text" size=2 name=compmo 
    
    MAXLENGTH=2  
    onKeyUp="if(this.value.length==this.size)docum
    
    ent.form.compday.focus();"> 
    
    <INPUT TYPE="text" size=2 name=compday 
    
    MAXLENGTH=2  
    onKeyUp="if(this.value.length==this.size)docum
    
    ent.form.compyear.focus();">
     
    <INPUT TYPE="text" size=4 name=compyear 
    
    MAXLENGTH=4  
    onKeyUp="if(this.value.length==this.size)docum
    
    ent.form.ordno.focus();">Date Completed<br>
     
    <INPUT TYPE="text" size=4 
    
    name=ordno>Order# -  If Insp<p> 
    <p> 
    <INPUT type=submit value="submit data"/> 
    <BR></form>
    
    <script type="text/javascript"><!--
    var gaJsHost = (("https:" == 
    
    document.location.protocol) ? "https://ssl." : 
    
    "http://www.");
    document.write(unescape("%3Cscript src='" + 
    
    gaJsHost + "google-analytics.com/ga.js' 
    
    type='text/javascript'%3E%3C/script%3E"));
    //-->
    </script>
    
    <script type="text/javascript">
    try {
    var pageTracker = 
    
    _gat._getTracker("UA-256751-2");
    pageTracker._trackPageview();
    } catch(err) {}
    
    </script>
    </body></html>

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    The error you have posted is a MySQL error due to you not having enough or too many values in your MySQL query, you will need to double check you table against your query and try running your script again.

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    resolved - thanks


Bookmarks

Posting Permissions

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