Page 1 of 1

function not working

Posted: Sun Oct 10, 2010 8:47 pm
by scifirocket
I have this function that is supposed to grab entries from a database using PHP and SQL and show results as the user types:

Code: Select all

$(document).ready(function() {
   $("searchb").change(function () {
      $.post("searchtest.php", {partialName: $(this).val()},function(data) {
         $("#results").html(data);
      });
   });  
});
this code references this text field:
[text]<p class="em_text"> <input id="searchb" type="text"/></p>[/text]

i ran firebug, and it reports no errors. what could be the problem?

Re: function not working

Posted: Fri Oct 15, 2010 1:26 am
by cpetercarter
You have given your input field an id "searchb", but no name attribute. Surely the field requires a "name", otherwise the form of which it is part will be unable to submit the contents of the field as GET or POST data. Your jQuery code $('searchb') is looking for an element with the name 'searchb', not one with an id 'searchb'. If you want the latter, you need $("#searchb"). But, as I say, I think that adding name="searchb" to the input field is probably what you intended to do.