
October 1st, 2012, 07:15 AM
|
 |
Lurker - in your bushes
|
|
Join Date: Nov 2000
Location: .be
|
|
|
JQuery UI: autocomplete with options:selected
Dear Devshed denizens,
I want to use an autocomplete on an input field, and select what sort of table/data it pulls WRT the dropdown that follows it:
html:
PHP Code:
<input type="text" name="quicksearch" id="quicksearch" value="Search candidates" />
<br />
<select name="quicksearch_type" id="quicksearch_type" onChange="LoadQSHiddn();">
<option value="cand_id">Candidate ID</option>
<option value="username">Username/Login</option>
<option value="pers_id">Personal Nr</option>
<option value="cname">Current Name</option>
<option value="lname">Family name at birth</option>
<option value="fname">First Name</option>
<option value="email">Email</option>
</select>
<input type="hidden" id="hiddn_qs_type" value="cand_id" readonly />
<script type="text/javascript">
//temp function to copy the value of quicksearch_type into the value field of #hiddn_qs_type
function LoadQSHiddn()
{
var t_val = $('#quicksearch_type option:selected').val();
$('#hiddn_qs_type').val(t_val);
}
//load autocomplete with the type selected from the dropdown (copied in the hidden field)
$(function() {
$( "#quicksearch" ).autocomplete({source: "./inc/inc_quicksearch.cfm?filter=" +$('#hiddn_qs_type').val(),minLength: 2});
});
</script>
My problem is that no matter what I select in the dropdown, it's always set as: cand_id (which was the selected field when the page loaded)
__________________
Saintaw
pending.
|