Need help with my first test of Ajax
I have made a simple php form where the user types in a first name and the php part finds names that match on the first letter(s) typed in. The names are stored in an array to keep it very simple.
Here is the html:
<body>
<form type="post" name="ajax_test" action="test_ajax.php">
<p>Enter first name (try entering a B)<br />Leave blank for all names</p>
<input id="input_box" type="input" name="first_name" value="<?php echo $rvars[first_name]; ?>"><br />
<input name="btnSubmit" type="submit" value="Next">
<input name="btnCancel" type="submit" value="Cancel">
</form>
</body>
So, the form calls itself. If there is a value in "first_name", the selection is done:
if($rvars[btnSubmit]) {
if ($rvars[first_name]) {
sort($names);
$result = preg_grep("/^" . $rvars[first_name] . "/i", $names);
if ($result) {
foreach($result as $value) {
echo $value . "<br />";
}
}
} else {
sort($names);
foreach($names as $value) {
echo $value . "<br />";
}
}
}
What I would like is for Ajax to do the same as pressing the btnSubmit on keyUp. I have a plugin defined so there is a delay between the keyUp's that is working. I just do not know the syntax for the action associated with the input box (id="input_box").
The executing test is at
here.
With appreciation...
Todd