pass other form elements to ajax suggestion box script
Posted
by
Alex Calder
on Stack Overflow
See other posts from Stack Overflow
or by Alex Calder
Published on 2011-11-20T17:30:09Z
Indexed on
2011/11/20
17:52 UTC
Read the original article
Hit count: 283
I paid somebody to build me a jQuery AJAX suggestion box script a while back. It works great. Now I'm trying to learn about it enough to modify it to do something different.
Right now, the script that generates the suggestions just takes the query text and does the same check every time. Now, I want to be able to pass along additional info so different things are looked for with each instance of a search box.
The HTML... simple, obvious.
input class="suggest" name="q" type="text" autocomplete="off" /
The jQuery looks like this:
jQuery(document).ready(function()
{
$('.suggest').autocomplete(
{
source:'output.php', minLength:3,
focus: function (event, ui)
{
$(event.target).val(ui.item.label);
return false;
}
}
);
[snip]
}
Instead of:
source:'output.php', minLength:3,
I'd like:
source:'output.php?arg1=blah1&arg2=blah2', minLength:3,
where arg1 and arg2 are passed along in the form...
input class="suggest" name="q" type="text" autocomplete="off" /
input type="hidden" name="arg1" value="blah1"
input type="hidden" name="arg2" value="blah2"
Does this make sense?
Thanks guys. I know just about "this much" about OOL's and javascript, so I'm learning...
Alex
© Stack Overflow or respective owner